dcmd_pullover(playerid,params[])
{
new giveplayerid, reason[128];
if(sscanf(params,"ds",giveplayerid,reason))
{
//They left out a parameter
}
if(!IsPlayerConnected(giveplayerid))
{
//The specified player is not connected
}
//They specified a connected player and a reason
//Do the rest
}
if(strcmp("/kick", cmdtext, true, 5) == 0) // "/kick" is 5 bytes long
{
if(strlen(cmdtext[6]) == 0) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /kick [ID] [MSG]");
//lenght of string at byte 6+, 0 if there is nothing there
new id = strval(cmdtext[6]);
//value of the string at byte 6+
if(IsPlayerConnected(id) == 0) return SendClientMessage(playerid, 0xFF0000AA, "Player not connected");
//check if the player is connected
new pos = strfind(cmdtext, " ", true, 6);
//get the position of the string after the space
if(pos == -1) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /kick [ID] [MSG]");
//pos will be -1 if there is no space
if(strlen(cmdtext[pos + 1]) == 0) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /kick [ID] [MSG]");
//check if there is a string after the space (pos is space, + 1 more byte)
new string[128];
format(string, sizeof(string), "ID %d has been kicked for %s", id, cmdtext[pos + 1]);
SendClientMessageToAll(0xFFFFFFFF, string);
//format your crap as needed
Kick(id);
//kick player
return 1;
}
Originally Posted by Lazarus
pawn Код:
|
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/pullover", cmdtext, true, 9) == 0) // "/pullover" is 9 bytes long
{
if(strlen(cmdtext[10]) == 0) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /kick [ID] [MSG]");
//lenght of string at byte 10+, 0 if there is nothing there
new id = strval(cmdtext[10]);
//value of the string at byte 10+
if(IsPlayerConnected(id) == 0) return SendClientMessage(playerid, 0xFF0000AA, "Player not connected");
//check if the player is connected
new pos = strfind(cmdtext, " ", true, 10);
//get the position of the string after the space
if(pos == -1) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /pullover [ID] [MSG]");
//pos will be -1 if there is no space
if(strlen(cmdtext[pos + 1]) == 0) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /pullover [ID] [MSG]");
//check if there is a string after the space (pos is space, + 1 more byte)
new string[128];
format(string, sizeof(string), "ID %d is being asked to pullover for %s", id, cmdtext[pos + 1]);
SendClientMessageToAll(0xFFFFFFFF, string);
//format your crap as needed
Pullover(id);
//kick player
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/pullover", cmdtext, true, 9) == 0)
{
if(strlen(cmdtext[10]) == 0) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /pullover [ID] [MSG]");
new id = strval(cmdtext[10]);
if(IsPlayerConnected(id) == 0) return SendClientMessage(playerid, 0xFF0000AA, "Player not connected");
new pos = strfind(cmdtext, " ", true, 10);
if(pos == -1) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /pullover [ID] [MSG]");
if(strlen(cmdtext[pos + 1]) == 0) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /pullover [ID] [MSG]");
new string[128];
format(string, sizeof(string), "ID %d is being asked to pullover for %s", id, cmdtext[pos + 1]);
SendClientMessage(id, 0xFFFFFFFF, string);
return 1;
}
Originally Posted by Lazarus
You can't just make up functions, Sidhu. If your unsure if it exists, look on the wiki:
https://sampwiki.blast.hk/wiki/Category:Scripting_Functions https://sampwiki.blast.hk/wiki/Scripting_Functions_Old |
Originally Posted by <3 HardStyle <3 | LarzI
Remember that sscanf has z (optional string).
And backwardsman, this is posted for Sidhu, it's not meant to post against you :P |
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1