20.07.2016, 14:01
How to make /jetpack and /announce and /spawn [player id] cmds?
CMD:say(playerid, params)
{
new str[128];
if(sscanf(params, "s", str)) return SendClientMessage(playerid, color, "usage /say [text]");
SendClientMessageToAllcolor, str);
Return 1;
}
CMD:spawn(playerid, params)
{
new str[128], id;
if(sscanf(params, "u", id)) return SendClientMessage(playerid, color, "usage /spawn player");
if(id == INVALID_PLAYER_ID) return SendClientMesage(...)
SpawnPlayer(id);
return 1;
}
CMD:spawn(playerid,params[])
{
new giveid;
if(sscanf(params, "u",giveid )) return SendClientMessage(playerid, color, "usage /spawn [playerid]");
SpawnPlayer(giveid);
return 1;
}
Use sscanf+izcmd
Izcmd: https://www.******.co.il/search?q=iz...T0BIXfUe6ZqMAM Sscanf2: https://sampforum.blast.hk/showthread.php?tid=570927 PHP код:
|
CMD:say(playerid, params[]) { if(isnull(params)) return SendClientMessage(playerid, color, "usage /say [text]"); SendClientMessageToAll(color, params); Return 1; } CMD:spawn(playerid, params[]) { if(isnull(params)) return SendClientMessage(playerid, color, "usage /spawn [id]"); new ID = strval(params); if(!IsPlayerConnected(ID) return 0; SpawnPlayer(ID); Return 1; }
Use isnull:
Код:
CMD:say(playerid, params[]) { if(isnull(params)) return SendClientMessage(playerid, color, "usage /say [text]"); SendClientMessageToAll(color, params); Return 1; } CMD:spawn(playerid, params[]) { if(isnull(params)) return SendClientMessage(playerid, color, "usage /spawn [id]"); new ID = strval(params); if(!IsPlayerConnected(ID) return 0; SpawnPlayer(ID); Return 1; } |