23.01.2011, 03:49
This is a multiple parameter command, and i have some trouble with her:
It should be like this:
You type: /pm location whizion - and it sends your location to a player named whizion (but it doesn't do nothing).
You type: /pm message whizion yo sup' - and it sends a PM with text: you sup' to a player named whizion (but it doesn't do nothing).
The only thing that's working is /pm stop, but that's really useless if other things don't work.
What am i doing wrong here? Please help, thanks.
pawn Код:
cmd(pm, playerid, params[]) // PM Command.
{
if(IsPlayerConnected(playerid))
{
new pl, opt[16], msg[64], str[128];
if(sscanf(params, "s[16]", opt))
{
SendClientMessage(playerid,COLOR_HELP,"USAGE: /pm [location/message/stop]");
return 1;
}
if(!strcmp(opt, "location", true)) // Sends a player your location.
{
if(sscanf(params, "s[16]u", opt, pl))
{
SendClientMessage(playerid,COLOR_HELP,"USAGE: /pm [location/message/stop] [ID/PartOfName]");
return 1;
}
if(GetPVarInt(pl, "StopPM") == 0)
{
new Float:px, Float:py, Float:pz;
GetPlayerPos(playerid, px, py, pz);
SetPlayerCheckpoint(pl, px, py, pz, 5.0);
format(str, sizeof(str), "PM: %s has PM-ed you his location. He's marked RED on your radar.", PlayerName[playerid]);
SendClientMessage(pl, COLOR_RED, str);
}
else { SendClientMessage(playerid,COLOR_ERROR,"ERROR: This person has blocked PM's."); }
}
else if(!strcmp(opt, "message", true)) // Sends a message to a player.
{
if(sscanf(params, "s[16]us[64]", opt, pl, msg))
{
SendClientMessage(playerid,COLOR_HELP,"USAGE: /pm [location/message/stop] [ID/PartOfName] [message]");
return 1;
}
if(GetPVarInt(pl, "StopPM") == 0)
{
format(str, sizeof(str), "PM: %s says: %s.", PlayerName[playerid], msg);
SendClientMessage(pl, COLOR_RED, str);
}
else { SendClientMessage(playerid,COLOR_ERROR,"ERROR: This person has blocked PM's."); }
}
else if(!strcmp(opt, "stop", true)) // Stops PM's from being send to you.
{
if(GetPVarInt(playerid, "StopPM") > 0) { SetPVarInt(playerid, "StopPM", 0); SendClientMessage(playerid,COLOR_GREEN,"INFO: PM's Activated."); }
else { SetPVarInt(playerid, "StopPM", 1); SendClientMessage(playerid,COLOR_RED,"INFO: PM's Blocked."); }
}
}
return 1;
}
You type: /pm location whizion - and it sends your location to a player named whizion (but it doesn't do nothing).
You type: /pm message whizion yo sup' - and it sends a PM with text: you sup' to a player named whizion (but it doesn't do nothing).
The only thing that's working is /pm stop, but that's really useless if other things don't work.
What am i doing wrong here? Please help, thanks.