dcmd_poke(playerid, params[])
{
new id;
if(sscanf(params, "u", id)) SendClientMessage(playerid, COLOR_YELLOW, "[USAGE]:[/]poke <id>");
else if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_RED, "[ERROR] player is not connected!");
else SendClientMessage(playerid, COLOR_RED, "[ERROR] You can't poke yourself?");
return 1;
}
|
Also, for the records: INVALID_PLAYER_ID is translated to 65535 or some number like that after compiling. That means you're checking if id equals to 65535, dumb, right? Use IsPlayerConnected(id) instead.
|
dcmd_poke(playerid,params[])
{
new ID;
if(sscanf(params, "u",ID)) return SendClientMessage(playerid, -1, "/poke [PlayerID]");
if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, -1, "Player is not connected.");
if(playerid == ID) return SendClientMessage(playerid, -1, "Dumbass, you can't poke yourself..");
new string[128]; // Limit is 128 characters, ofc you can reduce it
format(string,sizeof(string),"Ouch, %s has poked you", GetName(playerid));
SendClientMessage(ID, -1, string);
format(string,sizeof(string),"[INFO] You have poked %s", GetName(ID));
SendClientMessage(playerid, -1, string);
return 1;
}
|
What the fuck are you even saying... When a player is not connected, the Sscanf returns the value of 'playerid' as INVALID_PLAYER_ID (65535) which is constant at all conditions and it's far more easier and faster to compare two values rather than using a different function, which will absolutely do the same.
|
dcmd_poke(playerid, params[])
{
new id;
if(sscanf(params, "u", id)) SendClientMessage(playerid, COLOR_YELLOW, "[USAGE]:[/]poke <id>");
else if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_RED, "[ERROR] player is not connected!");
else if(playerid != id)
{
new string[128];
new pName[24];
new iName[24];
format(string, sizeof(string), "you poked %s (%d)", iName, id);
format(string, sizeof(string), "%s (%d) has poked you", pName, playerid);
SendClientMessage(id, COLOR_PPINK, string);
SendClientMessage(playerid, COLOR_PPINK, string);
return 1;
}
else SendClientMessage(playerid, COLOR_RED, "You can't poke yourself");
return 1;
}
|
Код:
dcmd_poke(playerid, params[])
{
new id;
if(sscanf(params, "u", id)) SendClientMessage(playerid, COLOR_YELLOW, "[USAGE]:[/]poke <id>");
else if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_RED, "[ERROR] player is not connected!");
else if(playerid != id)
{
new string[128];
new pName[24];
new iName[24];
format(string, sizeof(string), "you poked %s (%d)", iName, id);
format(string, sizeof(string), "%s (%d) has poked you", pName, playerid);
SendClientMessage(id, COLOR_PPINK, string);
SendClientMessage(playerid, COLOR_PPINK, string);
return 1;
}
else SendClientMessage(playerid, COLOR_RED, "You can't poke yourself");
return 1;
}
|
Format the string > send the message to the respective ID > format the string again > send the message to the other ID