ВСЕ КОМАНДЫ ВСТАВЛЯЮТСЯ в
public OnPlayerCommandText(playerid, cmdtext[])
{
СЮДА
return 0;
}
--------------------------------------------------------------------------------------------------------------------
STROK (в самый конец скрипта)
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; }
/lock ЗАКРЫТИЕ ДВЕРЕЙ В МАШИНАХ
if (strcmp(cmdtext, "/lock", true)==0) { if(IsPlayerInAnyVehicle(playerid)) { State=GetPlayerState(playerid); if(State!=PLAYER_STATE_DRIVER) { SendClientMessage(playerid,COLOR_GREY,"You can only lock the doors as the driver."); return 1; } new i; for(i=0;i<MAX_PLAYERS;i++) { if(i != playerid) { SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1); } } SendClientMessage(playerid, COLOR_GREY, "Vehicle locked!"); GetPlayerPos(playerid,X,Y,Z); PlayerPlaySound(playerid,1056,X,Y,Z); } else { SendClientMessage(playerid, COLOR_GREY, "You're not in a vehicle!"); } return 1; }
/unlock ОТКРЫТИЕ ДВЕРЕЙ В МАШИНАХ
if (strcmp(cmdtext, "/unlock", true)==0) { if(IsPlayerInAnyVehicle(playerid)) { State=GetPlayerState(playerid); if(State!=PLAYER_STATE_DRIVER) { SendClientMessage(playerid,COLOR_GREY,"You can only unlock the doors as the driver."); return 1; } new i; for(i=0;i<MAX_PLAYERS;i++) { SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 0); } SendClientMessage(playerid, COLOR_GREY, "Vehicle unlocked!"); GetPlayerPos(playerid,X,Y,Z); PlayerPlaySound(playerid,1057,X,Y,Z); } else { SendClientMessage(playerid, COLOR_GREY, "You're not in a vehicle!"); } return 1; }
ПАДЕНИЕ С 800 ФУТОВ (с парашютом)
if(strcmp(cmd, "/bigfall", true) == 0) { if(IsPlayerInAnyVehicle(playerid)) { new Float:X; new Float:Y; new Float:Z; new VehicleID; GetPlayerPos(playerid, X, Y, Z); VehicleID = GetPlayerVehicleID(playerid); SetVehiclePos(VehicleID, X, Y, Z + 800.00); SetPlayerFacingAngle(playerid,Ang); GivePlayerWeapon(playerid,46,1); } else { new Float:X; new Float:Y; new Float:Z; GetPlayerPos(playerid, X, Y, Z); SetPlayerPos(playerid, X, Y, Z + 800.00); SetPlayerFacingAngle(playerid,Ang); GivePlayerWeapon(playerid,46,1); GameTextForPlayer(playerid, "~w~Weeeeeeeeeeeeeeeeee!!",8000,5); } return 1; }
КОМАНДА ДЛЯ ОЧИСТКИ ЧАТА - /clearchat
if(strcmp(cmdtext,"/clearchat",true)==0) // Chat window is gone, fomg! { SendClientMessage(playerid,COLOR_GREY," "); SendClientMessage(playerid,COLOR_GREY," "); SendClientMessage(playerid,COLOR_GREY," "); SendClientMessage(playerid,COLOR_GREY," "); SendClientMessage(playerid,COLOR_GREY," "); SendClientMessage(playerid,COLOR_GREY," "); SendClientMessage(playerid,COLOR_GREY," "); SendClientMessage(playerid,COLOR_GREY," "); SendClientMessage(playerid,COLOR_GREY," "); SendClientMessage(playerid,COLOR_GREY," "); return 1; }
СМЕНА ВРЕМЕНИ СУТОК НА НОЧЬ
if (strcmp(cmdtext, "/night", true)==0) { /* Do something here */ SetWorldTime(0); GameTextForPlayer(playerid,"~b~notte ~b~oscura ~g~LOL",5000,5); return 1; }
СМЕНА ВРЕМЕНИ СУТОК НА ДЕНЬ
if (strcmp(cmdtext, "/day", true)==0) { /* Do something here */ SetWorldTime(12); GameTextForPlayer(playerid,"~p~Giorno ~p~Felice ~p~LOL",5000,5); return 1; }
КОМАНДА ДЛЯ АДМИНОВ /slap отнять у игрока 20 HP
new string[256]; new adminname[256]; new playername[256]; new id; new tmp[256]; new cmd[256]; new Float:health, Float:x, Float:y, Float:z; new idx; cmd = strtok(cmdtext, idx); if(strcmp(cmd, "/slap", true) == 0 && IsPlayerAdmin(playerid)==1) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "Usage: /slap <playerid>"); return 1; } if(!IsPlayerAdmin(playerid)) { SendClientMessage(playerid, COLOR_WHITE, "You haven't got any admin rights"); return 1; } id = strval(tmp); if(IsPlayerConnected(id)) { GetPlayerPos(id, x, y, z); PlayerPlaySound(id, 1190, x, y, z); SetPlayerPos(id, x, y, z+2); GetPlayerHealth(id, health); SetPlayerHealth(id, health-20); GetPlayerName(id, playername, 256); GetPlayerName(playerid, adminname, 256); format(string, sizeof(string), "%s slaps %s with a large fish!! /*You can also add some other text here to your likings..*/", adminname, playername); SendClientMessageToAll(COLOR_PINK, string); /*format(string, sizeof(string), "%s slapped you!!", adminname); SendClientMessage(id, COLOR_WHITE, string);*/ } else { format(string, sizeof(string), "%d is not an active player.", id); SendClientMessage(playerid, COLOR_WHITE, string); } return 1; }
ТЕЛЕПОРТИРОВАТЬ ВСЕХ ИГРОКОВ
if(strcmp(cmdtext, "/getallplayers", true) == 0) { new Float:x; new Float:y; new Float:z; for(new i=0; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i)) { GetPlayerPos(playerid,x,y,z); SetPlayerPos(i,x,y,z+10); } return 1; }
100% здоровье
if (strcmp(cmdtext, "/health", true)==0) { if(GetPlayerMoney(playerid) > 4999){ GivePlayerMoney(playerid, GetPlayerMoney(playerid) - 5000); SetPlayerHealth(playerid,100); } else{ SendClientMessage(playerid,COLOR_RED,"Not enough money."); } return 1; }
ПОКАЗАТЬ ДАТУ И ВРЕМЯ НА СЕРВЕРЕ /time
new string[MAX_STRING]; if (strcmp(cmdtext, "/time", true)==0) { new Hours; new Minutes; new Seconds; new Days; new Months; new Years; gettime(Hours, Minutes, Seconds); getdate(Years, Months, Days); format(string, sizeof(string), "Date: %d/%d/%d, Time %d:%d:%d", Days,Months,Years,Hours,Minutes,Seconds); SendClientMessage(playerid,COLOR_GREEN,string); return 1; }
100% здоровье на халяву
if (strcmp(cmdtext, "/health", true)==0) { SetPlayerHealth(playerid, 100); return 1; }
Деньги на халяву
if (strcmp(cmdtext, "/cash", true)==0) { SendClientMessage(playerid,COLOR_GREEN,"Ты богатый чувак!"); GivePlayerMoney (playerid, 1000000); return 1; }
Бензин
В самом начале добавить:
#define COLOR_RED 0xAA3333AA // #define COLOR_WHITE 0xFFFFFFAA // #define TIME 3000 // время за сколько бензин кончится #define AMOUNT 100 // new Petrol[MAX_PLAYERS];
Функция бензина
public CheckFuel(playerid) { for(new i=0; i<MAX_PLAYERS; i++) { new Ptmess[32]; if(GetPlayerState(i) == 2) { if(Petrol[i] >= 1) { Petrol[i]--; format(Ptmess, sizeof(Ptmess), "~w~Petrol ->~r~%d", Petrol[i]); GameTextForPlayer(i, Ptmess, 500, 4); } else { RemovePlayerFromVehicle(i); SendClientMessage(i, COLOR_RED, "You ran out of petrol"); } if(Petrol[i] >=51) { format(Ptmess, sizeof(Ptmess), "~w~Petrol ->%d", Petrol[i]); GameTextForPlayer(i, Ptmess, 500, 4); } } } return 1; }
В OnGameModeInit:
SetTimer("CheckFuel", TIME, 1);
В OnPlayerSpawn добавить :
for(new p=0;p<MAX_PLAYERS;p++) { Petrol[p] = AMOUNT; }
В OnPlayerCommandText добавить:
if(strcmp(cmd, "/fuel", true) == 0) { for(new p=0;p<MAX_PLAYERS;p++) { if(GetPlayerMoney(p) > 199) { Petrol[p] = AMOUNT; GivePlayerMoney(p,-200);// - 200 - цена бензина SendClientMessage(p, COLOR_WHITE, ">Тачка заправлена"); } else { SendClientMessage(p, COLOR_RED, ">Недостаточно денег!"); } } return 1; }
Команда для смены цвета игрока
new playerColors[100] = { 0xFF8C13FF,0xC715FFFF,0x20B2AAFF,0xDC143CFF,0x6495EDFF,0xf0e68cFF,0x778899FF,0xFF1493FF,0xF4A460FF,0xEE82EEFF,0xFFD720FF, 0x8b4513FF,0x4949A0FF,0x148b8bFF,0x14ff7fFF,0x556b2fFF,0x0FD9FAFF,0x10DC29FF,0x534081FF,0x0495CDFF,0xEF6CE8FF,0xBD34DAFF, 0x247C1BFF,0x0C8E5DFF,0x635B03FF,0xCB7ED3FF,0x65ADEBFF,0x5C1ACCFF,0xF2F853FF,0x11F891FF,0x7B39AAFF,0x53EB10FF,0x54137DFF, 0x275222FF,0xF09F5BFF,0x3D0A4FFF,0x22F767FF,0xD63034FF,0x9A6980FF,0xDFB935FF,0x3793FAFF,0x90239DFF,0xE9AB2FFF,0xAF2FF3FF, 0x057F94FF,0xB98519FF,0x388EEAFF,0x028151FF,0xA55043FF,0x0DE018FF,0x93AB1CFF,0x95BAF0FF,0x369976FF,0x18F71FFF,0x4B8987FF, 0x491B9EFF,0x829DC7FF,0xBCE635FF,0xCEA6DFFF,0x20D4ADFF,0x2D74FDFF,0x3C1C0DFF,0x12D6D4FF,0x48C000FF,0x2A51E2FF,0xE3AC12FF, 0xFC42A8FF,0x2FC827FF,0x1A30BFFF,0xB740C2FF,0x42ACF5FF,0x2FD9DEFF,0xFAFB71FF,0x05D1CDFF,0xC471BDFF,0x94436EFF,0xC1F7ECFF, 0xCE79EEFF,0xBD1EF2FF,0x93B7E4FF,0x3214AAFF,0x184D3BFF,0xAE4B99FF,0x7E49D7FF,0x4C436EFF,0xFA24CCFF,0xCE76BEFF,0xA04E0AFF, 0x9F945CFF,0xDCDE3DFF,0x10C9C5FF,0x70524DFF,0x0BE472FF,0x8A2CD7FF,0x6152C2FF,0xCF72A9FF,0xE59338FF,0xEEDC2DFF,0xD8C762FF, 0x3FE65CFF }; public OnPlayerCommandText(playerid, cmdtext[]) { new idx; new cmd[256]; cmd = strtok(cmdtext, idx); if(strcmp(cmd, "/color", true) == 0) { GetPlayerName(playerid, playername, sizeof(playername)); tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "* Набери: /color [0-99]"); return 1; } if (strval(tmp)>99||strval(tmp)<0) { SendClientMessage(playerid, COLOR_WHITE, "* Набери: /color [0-99]"); return 1; } else { SetPlayerColor(playerid,playerColors[strval(tmp)]); SendClientMessage(playerid, playerColors[strval(tmp)], "* Вы поменяли цвет."); return 1; } return 1; }
Команда /givegun
if((strcmp(cmd, "/givegun", true) == 0) && (IsPlayerAdmin(playerid))) { new tmp[256]; tmp = strtok(cmdtext, idx); new gunID = strval(tmp); if(!strlen(tmp)) { SendClientMessage(playerid,COLOR_RED,"***Используй: /givegun [gunID] [playerID]"); } else { if(gunID > 46) { SendClientMessage(playerid,COLOR_RED,"***Ошибка: ID оружия идет от 1 до 46"); } else { tmp = strtok(cmdtext, idx); new pID = strval(tmp); new string[256]; if(strlen(tmp)) { if(IsPlayerConnected(pID)) { format(string, sizeof(string), "***Админ %s дал вам оружее - %s.", PlayerName(playerid), WeaponNAME(gunID)); SendClientMessage(pID,COLOR_WHITE, string); GivePlayerWeapon(pID,gunID,3000); format(string, sizeof(string), "***Вы дали %s оружее - %s.", PlayerName(pID), WeaponNAME(gunID)); SendClientMessage(playerid,COLOR_WHITE, string); } else { SendClientMessage(playerid,COLOR_WHITE, "***Нет такого юзера."); } } else { format(string, sizeof(string), "***Админ всем дал оружее - %s.", WeaponNAME(gunID)); SendClientMessageToAll(COLOR_WHITE, string); for(new i = 0; i < MAX_PLAYERS; i++) { GivePlayerWeapon(i,gunID,3000); } } } } return 1; }
Команда исчезновения на карте и появления
В начало:
new playerColors[100] = { 0xFF8C13FF,0xC715FFFF,0x20B2AAFF,0xDC143CFF,0x6495EDFF,0xf0e68cFF,0x778899FF,0xFF1493FF,0xF4A460FF,0xEE82EEFF,0xFFD720FF, 0x8b4513FF,0x4949A0FF,0x148b8bFF,0x14ff7fFF,0x556b2fFF,0x0FD9FAFF,0x10DC29FF,0x534081FF,0x0495CDFF,0xEF6CE8FF,0xBD34DAFF, 0x247C1BFF,0x0C8E5DFF,0x635B03FF,0xCB7ED3FF,0x65ADEBFF,0x5C1ACCFF,0xF2F853FF,0x11F891FF,0x7B39AAFF,0x53EB10FF,0x54137DFF, 0x275222FF,0xF09F5BFF,0x3D0A4FFF,0x22F767FF,0xD63034FF,0x9A6980FF,0xDFB935FF,0x3793FAFF,0x90239DFF,0xE9AB2FFF,0xAF2FF3FF, 0x057F94FF,0xB98519FF,0x388EEAFF,0x028151FF,0xA55043FF,0x0DE018FF,0x93AB1CFF,0x95BAF0FF,0x369976FF,0x18F71FFF,0x4B8987FF, 0x491B9EFF,0x829DC7FF,0xBCE635FF,0xCEA6DFFF,0x20D4ADFF,0x2D74FDFF,0x3C1C0DFF,0x12D6D4FF,0x48C000FF,0x2A51E2FF,0xE3AC12FF, 0xFC42A8FF,0x2FC827FF,0x1A30BFFF,0xB740C2FF,0x42ACF5FF,0x2FD9DEFF,0xFAFB71FF,0x05D1CDFF,0xC471BDFF,0x94436EFF,0xC1F7ECFF, 0xCE79EEFF,0xBD1EF2FF,0x93B7E4FF,0x3214AAFF,0x184D3BFF,0xAE4B99FF,0x7E49D7FF,0x4C436EFF,0xFA24CCFF,0xCE76BEFF,0xA04E0AFF, 0x9F945CFF,0xDCDE3DFF,0x10C9C5FF,0x70524DFF,0x0BE472FF,0x8A2CD7FF,0x6152C2FF,0xCF72A9FF,0xE59338FF,0xEEDC2DFF,0xD8C762FF, 0x3FE65CFF };
В OnPlayerSpawn:
SetPlayerColor(playerid, playerColors[playerid]);
В OnPlayerCommandText:
if(strcmp(cmd, "/invisible", true) == 0) { SetPlayerColor(playerid, 0x00000000); SendClientMessage(playerid, COLOR_ORANGE, "Ты невидимка"); return 1; } else if(strcmp(cmd, "/visible", true) == 0) { SetPlayerColor(playerid, playerColors[playerid]); SendClientMessage(playerid, COLOR_ORANGE, "Тебя видно"); return 1; }