27.02.2010, 13:37
Start using dcmd or zcmd with sscanf, much simpler than calling strtok all the time.
Oh, btw, use the switch function for those gunid's instead of 50 times else if.
pawn Код:
dcmd_event(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_RED, "Not admin");
new
event[32],
gunid,
ammo;
if(sscanf(params, "sii", event, gunid, ammo)) return SendClientMessage(playerid, COLOR_RED, "Usage: /event ...");
if(!strcmp(event, "guns"))
{
GivePlayerWeapon(playerid, gunid, ammo);
// or whatever should happen if an admin types /event guns ..
}
if(!strcmp(event, "health))
{
SetPlayerHealth(playerid, 100.0);
}
if(!strcmp(event, "teleport))
{
SetPlayerPos(playerid, 0.0, 0.0, 5.0);
}
return 1;
}