26.07.2012, 11:21
pawn Код:
CMD:lasercol(playerid, params[])
{
if(isnull(params)) return SendClientMessage(playerid, C_GREY, "USAGE: /lasercol [color]");
if(!strcmp(params, "red", true)) SetPVarInt(playerid, "color", 19080);
else if(!strcmp(params, "blue", true)) SetPVarInt(playerid, "color", 18643);
else if(!strcmp(params, "pink", true)) SetPVarInt(playerid, "color", 19081);
else if(!strcmp(params, "orange", true)) SetPVarInt(playerid, "color", 19082);
else if(!strcmp(params, "green", true)) SetPVarInt(playerid, "color", 19083);
else if(!strcmp(params, "yellow", true)) SetPVarInt(playerid, "color", 19084);
else SendClientMessage(playerid, C_VIOLET, "Color not available!");
return 1;
}
2. strcmp returns 0 when it matches, so I added a ! before strcmp().
3. No need to use sscanf. sscanf is for SPLITTING strings with MULTIPLE parameters. Waste of memory and CPU.
4. sscanf returns 1 if the input is invalid, so your code would NEVER work because you basically said 'if sscanf is invalid, process input'.