/*------------------------------------------------------------------------------ ** locked.amx ** (Filter Script) copyright ALMEIDA 2007/8/18 " /lock " を入力すると、乗車中の車両を施錠します。 この施錠はタイマー式で、自動で開錠されます。 サーバー内に乗れない車両ばかりになる事態を防ぎます ------------------------------------------------------------------------------*/ #include #define COLOR_YELLOW 0xFFFF00AA #define COLOR_ORANGE 0xFF9900AA #define COLOR_CRIMSONRED 0xFF000000 #define COLOR_WHITE 0xFFFFFFAA #define COLOR_SYSTEM COLOR_WHITE #define COLOR_DEBUG 0x00EEADDF #define unlocktime 120 // 鍵を施錠している秒数です. 標準 : 120秒 #define playsound forward Vehicleunlockedtimer(playerid, lockedcarid); public OnFilterScriptInit() { SendClientMessageToAll(COLOR_DEBUG, "Loading success locked.amx"); return 1; } public OnFilterScriptExit() { SendClientMessageToAll(COLOR_DEBUG, "unloading success locked.amx"); return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { new string[256]; new name[MAX_PLAYERS]; new cmd[256]; new idx; cmd = strtok(cmdtext, idx); if (strcmp(cmd, "/lock", true)==0) { if (IsPlayerInAnyVehicle(playerid)) { if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER) { SendClientMessage(playerid, COLOR_CRIMSONRED, "施錠できるのは運転手だけです"); return 1; } new lockedcarid = GetPlayerVehicleID(playerid); for (new i = 0; i < MAX_PLAYERS; i++) { if (i != playerid) { SetVehicleParamsForPlayer(lockedcarid, i, 0, 1); } } GetPlayerName(playerid, name, sizeof(name)); GameTextForPlayer(playerid, "~r~Vehicle locked !!!!", 3000, 1); SendClientMessage(playerid, COLOR_ORANGE, "鍵を掛けました!"); format(string, sizeof(string), "** %s は VehicleID %d に施錠しました **", name, lockedcarid); SendClientMessageToAll(COLOR_YELLOW, string); #if defined playsound PlayerPlaySound(playerid, 1056, Float:0.0, Float:0.0, Float:0.0); #endif SetTimerEx("Vehicleunlockedtimer", unlocktime * 1000, 0, "%d", playerid, lockedcarid); } else { SendClientMessage(playerid, COLOR_CRIMSONRED, "車両に乗って再度実行してください"); } return 1; } return 0; } public Vehicleunlockedtimer(playerid, lockedcarid) { for (new i = 0; i < MAX_PLAYERS; i++) { SetVehicleParamsForPlayer(lockedcarid, i, 0, 0); } return 1; } strtok(const string[], &index) { new length = strlen(string); while ((index < length) && (string[index] <= ' ')) { index++; } new offset = index; new result[20]; while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1))) { result[index - offset] = string[index]; index++; } result[index - offset] = EOS; return result; }