SSCANF2 : https://sampforum.blast.hk/showthread.php?tid=570927 ZCMD : http://www.solidfiles.com/d/d20f/ |
#include <a_samp> #include <zcmd> #include <sscanf2>
new bool:IsCuffed[MAX_PLAYERS];
public OnPlayerConnect(playerid) { IsCuffed[playerid] = false; return 1; }
#define LSPD 0 #define GANG 1
CMD:cuff(playerid, params[]) { // do something here return 1; }
CMD:cuff(playerid, params[]) { if(gTeam[playerid] == LSPD) { // do something here return 1; } else if(gTeam[playerid] != LSPD) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: Only cops and use this command!"); return 1; } return 1; }
CMD:cuff(playerid, params[]) { if(gTeam[playerid] == LSPD) { new targetid; if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, 0xFF00FF, "USAGE: /cuff (PlayerID)"); return 1; } else if(gTeam[playerid] != LSPD) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: Only cops and use this command!"); return 1; } return 1; }
CMD:cuff(playerid, params[]) { if(gTeam[playerid] == LSPD) { new targetid; if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, 0xFF00FF, "USAGE: /cuff (PlayerID)"); if(IsPlayerConnected(targetid)) { // do something here return 1; } else if(!IsPlayerConnected(targetid)) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: Invalid ID!"); return 1! } return 1; } else if(gTeam[playerid] != LSPD) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: Only cops and use this command!"); return 1; } return 1; }
CMD:cuff(playerid, params[]) { if(gTeam[playerid] == LSPD) { new targetid; if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, 0xFF00FF, "USAGE: /cuff (PlayerID)"); if(IsPlayerConnected(targetid)) { new Float:x, Float:y, Float:z; GetPlayerPos(targetid, x, y, z); if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) { // do something here return 1; } else if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: That player is too far away from you!"); return 1; } return 1; } else if(!IsPlayerConnected(targetid)) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: Invalid ID!"); return 1! } return 1; } else if(gTeam[playerid] != LSPD) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: Only cops and use this command!"); return 1; } return 1; }
CMD:cuff(playerid, params[]) { if(gTeam[playerid] == LSPD) { new targetid; if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, 0xFF00FF, "USAGE: /cuff (PlayerID)"); if(IsPlayerConnected(targetid)) { new Float:x, Float:y, Float:z; GetPlayerPos(targetid, x, y, z); if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) { if(gTeam[playerid] != LSPD) { // do something here return 1; } else if(gTeam[playerid] == LSPD) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: you can't cuff a law enforcer!"); return 1; { return 1; } else if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: That player is too far away from you!"); return 1; } return 1; } else if(!IsPlayerConnected(targetid)) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: Invalid ID!"); return 1! } return 1; } else if(gTeam[playerid] != LSPD) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: Only cops and use this command!"); return 1; } return 1; }
CMD:cuff(playerid, params[]) { if(gTeam[playerid] == LSPD) { new targetid; if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, 0xFF00FF, "USAGE: /cuff (PlayerID)"); if(IsPlayerConnected(targetid)) { new Float:x, Float:y, Float:z; GetPlayerPos(targetid, x, y, z); if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) { if(gTeam[playerid] != LSPD) { if(IsCuffed == false) { // do something here return 1; } else if(IsCuffed[targetid] == true) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: This player is already cuffed!"); return 1; } return 1; } else if(gTeam[playerid] == LSPD) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: you can't cuff a law enforcer!"); return 1; { return 1; } else if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: That player is too far away from you!"); return 1; } return 1; } else if(!IsPlayerConnected(targetid)) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: Invalid ID!"); return 1! } return 1; } else if(gTeam[playerid] != LSPD) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: Only cops and use this command!"); return 1; } return 1; }
CMD:cuff(playerid, params[]) { if(gTeam[playerid] == LSPD) { new targetid; if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, 0xFF00FF, "USAGE: /cuff (PlayerID)"); if(IsPlayerConnected(targetid)) { new Float:x, Float:y, Float:z; GetPlayerPos(targetid, x, y, z); if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) { if(gTeam[playerid] != LSPD) { if(IsCuffed[targetid] == false) { new string[64+MAX_PLAYER_NAME] new targetname[MAX_PLAYER_NAME] new playername[MAX_PLAYER_NAME] GetPlayerName(playerid, playername, sizeof(playername) format(string, sizeof(string), "You have been cuffed by officer %s",playername)); SendClientMessage(targetid, 0x0000FF, string); GetPlayerName(targetid, targetname, sizeof(targetname)) format(string, sizeof(string), "You have cuffed %s ", targetname)) SendClientMessage(playerid, 0xCCFF00, string)); SetPlayerAttachedObject(targetid,8,19418,6,-0.031999,0.024000,-0.024000,-7.900000,-32.000011,-72.299987,1.115998,1.322000,1.406000); SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED); IsCuffed = true; return 1; } else if(IsCuffed == true) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: This player is already cuffed!"); return 1; } return 1; } else if(gTeam[playerid] == LSPD) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: you can't cuff a law enforcer!"); return 1; { return 1; } else if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: That player is too far away from you!"); return 1; } return 1; } else if(!IsPlayerConnected(targetid)) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: Invalid ID!"); return 1! } return 1; } else if(gTeam[playerid] != LSPD) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: Only cops and use this command!"); return 1; } return 1; }
CMD:uncuff(playerid, params[]) { if(gTeam[playerid] == LSPD) { new targetid; if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, 0xFF00FF, "USAGE: /uncuff (PlayerID)"); if(IsPlayerConnected(targetid)) { new Float:x, Float:y, Float:z; GetPlayerPos(targetid, x, y, z); if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) { if(gTeam[playerid] != LSPD) { if(IsCuffed[targetid] == true) { new string[64+MAX_PLAYER_NAME] new targetname[MAX_PLAYER_NAME] new playername[MAX_PLAYER_NAME] GetPlayerName(playerid, playername, sizeof(playername) format(string, sizeof(string), "You have been uncuffed by officer %s",playername)); SendClientMessage(targetid, 0x0000FF, string); GetPlayerName(targetid, targetname, sizeof(targetname)) format(string, sizeof(string), "You have uncuffed %s ", targetname)) SendClientMessage(playerid, 0xCCFF00, string)); if(IsPlayerAttachedObjectSlotUsed(targetid, 8)) { RemovePlayerAttachedObject(targetid, 8); return 1; } SetPlayerSpecialAction(targetid, SPECIAL_ACTION_NONE); IsCuffed = false; return 1; } else if(IsCuffed == true) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: This player is not cuffed!"); return 1; } return 1; } else if(gTeam[playerid] == LSPD) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: you can't use this on a law enforcer!"); return 1; { return 1; } else if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: That player is too far away from you!"); return 1; } return 1; } else if(!IsPlayerConnected(targetid)) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: Invalid ID!"); return 1! } return 1; } else if(gTeam[playerid] != LSPD) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: Only cops and use this command!"); return 1; } return 1; }
else if(gTeam[playerid] == LSPD) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: you can't use this on a law enforcer!"); return 1; { return 1;
else if(!IsPlayerConnected(targetid)) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: Invalid ID!"); return 1! }
Code:
else if(gTeam[playerid] == LSPD) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: you can't use this on a law enforcer!"); return 1; { return 1; Code:
else if(!IsPlayerConnected(targetid)) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: Invalid ID!"); return 1! } |
if(IsPlayerConnected(playerid))
{
// Some code ...
}
else
{
if(!IsPlayerConnected(playerid))
{
// Some other code ...
}
}
if(IsPlayerConnected(playerid))
{
// Some code ...
return 1;
}
else if(!IsPlayerConnected(playerid))
{
// Some other code ...
return 1;
}
if(condition)
{
// Some code...
return someValue;
}
// Code under this if statement is automatically the else statement, that is without explicitely using the else keyword.
return someOtherValue;
PHP Code:
|
While I usually don't complain about the excessive use of unnecessary else if statements, I do get annoyed by it. A lot of people find it reasonable to use them in a situation where the given condition can only be maximum two states and thus making an else if statement pointless and may even become "ineffective":
PHP Code:
PHP Code:
To drop the whole else statement altogether, the function would have to return a value in the if statement above that: PHP Code:
Here's another mistake I came across: EDIT: Your boolean variable 'isCuffed' will only work when nobody is cuffed. Once 1 player on the server is cuffed, nobody else can get cuffed. |
CMD:uncuff(playerid, params[])
{
if(gTeam[playerid] != LSPD)
return SendClientMessage(playerid, 0xFF0000, "[ERROR]: Only cops and use this command!");
new targetid; // To store the player id which is the target.
if(sscanf(params, "u", targetid))
return SendClientMessage(playerid, 0xFF00FF, "USAGE: /uncuff (PlayerID)"); // Store an ID (or INVALID_PLAYER_id if the playerid is wrong)
if(!IsPlayerConnected(targetid)) // The player is NOT ('!' mean NOT) connected so we return an error message
return SendClientMessage(playerid, 0xFF0000, "[ERROR]: Invalid ID!");
new // 3 variables to store x, y, z, target's coord.
Float:x,
Float:y,
Float:z;
GetPlayerPos(targetid, x, y, z); // Get these coord'
if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) // Check if the player is in the range of the target.
return SendClientMessage(playerid, 0xFF0000, "[ERROR]: That player is too far away from you!");
if(gTeam[targetid] == LSPD) // if the target is law enforcer
return SendClientMessage(playerid, 0xFF0000, "[ERROR]: you can't use this on a law enforcer!");
if(!IsCuffed[targetid]) // if the player is NOT cuffed so we can't uncuff him
return SendClientMessage(playerid, 0xFF0000, "[ERROR]: This player is not cuffed!");
new
string[35+MAX_PLAYER_NAME], // the string to send a message
targetname[MAX_PLAYER_NAME], // string to store the target's name
playername[MAX_PLAYER_NAME]; // string to store the player's name
GetPlayerName(playerid, playername, sizeof(playername); // Store the player name
format(string, sizeof(string), "You have been uncuffed by officer %s", playername)); // Send a formated message which %s is remplaced by player's name
SendClientMessage(targetid, 0x0000FF, string);
GetPlayerName(targetid, targetname, sizeof(targetname));
format(string, sizeof(string), "You have uncuffed %s ", targetname))
SendClientMessage(playerid, 0xCCFF00, string));
if(IsPlayerAttachedObjectSlotUsed(targetid, 8)) // If the player have an object (handcuff) » we check it
RemovePlayerAttachedObject(targetid, 8); // So remove the object
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_NONE); // Remove any special action
IsCuffed = false;
return 1;
}
There is some errors plus I don't like at all (it's personal) a code which is interlinked.
PHP Code:
|
CMD:uncuff(playerid, params[])
{
if(gTeam[playerid] != LSPD)
return SendClientMessage(playerid, 0xFF0000FF, "[ERROR]: Only cops and use this command!");
new targetid;
if(sscanf(params, "u", targetid))
return SendClientMessage(playerid, 0xFF00FFFF, "USAGE: /uncuff (PlayerID)");
if (targetid == INVALID_PLAYER_ID) // No need to call IsPlayerConnected
return SendClientMessage(playerid, 0xFF0000FF, "[ERROR]: Invalid ID!");
new
Float:x,
Float:y,
Float:z;
GetPlayerPos(targetid, x, y, z);
if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z))
return SendClientMessage(playerid, 0xFF0000FF, "[ERROR]: That player is too far away from you!");
if(gTeam[targetid] == LSPD)
return SendClientMessage(playerid, 0xFF0000FF, "[ERROR]: you can't use this on a law enforcer!");
if(IsCuffed[targetid] == false)
return SendClientMessage(playerid, 0xFF0000FF, "[ERROR]: This player is not cuffed!");
new
string[59]; // One string is enough, you can just reuse it.
GetPlayerName(playerid, string, 25);
format(string, sizeof (string), "You have been uncuffed by officer %s", string);
SendClientMessage(targetid, 0x0000FFFF, string);
GetPlayerName(targetid, string, 25);
format(string, sizeof (string), "You have uncuffed %s", string);
SendClientMessage(playerid, 0xCCFF00FF, string));
// No need to check if slot8 is used. If it is, it will remove the object, if it's not, the native will fail
RemovePlayerAttachedObject(targetid, 8);
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_NONE);
IsCuffed[targetid] = false; // You didn't add [targetid]
return 1;
}
#include <zcmd>
CMD:kill(playerid,params[])
{
SetPlayerHealth(playerid, 0.0);
return 1;
}
CMD:123(playerid,params[])
{
//do something here
return 1;
}
//And you can use COMMAD like this:
COMMAND:123(playerid,params[])
{
//do something here
return 1;
}
#include <a_samp> #include <zcmd> #include <sscanf2>
CMD:cuff(playerid, params[]) { if(gTeam[playerid] == LSPD) { new targetid; if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, 0xFF00FF, "USAGE: /cuff (PlayerID)"); if(IsPlayerConnected(targetid)) { new Float:x, Float:y, Float:z; GetPlayerPos(targetid, x, y, z); if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) { if(gTeam[playerid] != LSPD) { if(IsCuffed[targetid] == false) { new string[64+MAX_PLAYER_NAME] new targetname[MAX_PLAYER_NAME] new playername[MAX_PLAYER_NAME] GetPlayerName(playerid, playername, sizeof(playername) format(string, sizeof(string), "You have been cuffed by officer %s",playername)); SendClientMessage(targetid, 0x0000FF, string); GetPlayerName(targetid, targetname, sizeof(targetname)) format(string, sizeof(string), "You have cuffed %s ", targetname)) SendClientMessage(playerid, 0xCCFF00, string)); SetPlayerAttachedObject(targetid,8,19418,6,-0.031999,0.024000,-0.024000,-7.900000,-32.000011,-72.299987,1.115998,1.322000,1.406000); SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED); IsCuffed = true; return 1; } else if(IsCuffed == true) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: This player is already cuffed!"); return 1; } return 1; } else if(gTeam[playerid] == LSPD) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: you can't cuff a law enforcer!"); return 1; { return 1; } else if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: That player is too far away from you!"); return 1; } return 1; } else if(!IsPlayerConnected(targetid)) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: Invalid ID!"); return 1! } return 1; } else if(gTeam[playerid] != LSPD) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: Only cops and use this command!"); return 1; } return 1; }
CMD:uncuff(playerid, params[]) { if(gTeam[playerid] == LSPD) { new targetid; if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, 0xFF00FF, "USAGE: /uncuff (PlayerID)"); if(IsPlayerConnected(targetid)) { new Float:x, Float:y, Float:z; GetPlayerPos(targetid, x, y, z); if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) { if(gTeam[playerid] != LSPD) { if(IsCuffed[targetid] == true) { new string[64+MAX_PLAYER_NAME] new targetname[MAX_PLAYER_NAME] new playername[MAX_PLAYER_NAME] GetPlayerName(playerid, playername, sizeof(playername) format(string, sizeof(string), "You have been uncuffed by officer %s",playername)); SendClientMessage(targetid, 0x0000FF, string); GetPlayerName(targetid, targetname, sizeof(targetname)) format(string, sizeof(string), "You have uncuffed %s ", targetname)) SendClientMessage(playerid, 0xCCFF00, string)); if(IsPlayerAttachedObjectSlotUsed(targetid, 8)) { RemovePlayerAttachedObject(targetid, 8); return 1; } SetPlayerSpecialAction(targetid, SPECIAL_ACTION_NONE); IsCuffed = false; return 1; } else if(IsCuffed == true) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: This player is not cuffed!"); return 1; } return 1; } else if(gTeam[playerid] == LSPD) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: you can't use this on a law enforcer!"); return 1; { return 1; } else if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: That player is too far away from you!"); return 1; } return 1; } else if(!IsPlayerConnected(targetid)) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: Invalid ID!"); return 1! } return 1; } else if(gTeam[playerid] != LSPD) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: Only cops and use this command!"); return 1; } return 1; }
see here
https://sampforum.blast.hk/showthread.php?tid=618127 and add it in gm Код:
#include <a_samp> #include <zcmd> #include <sscanf2> Код:
CMD:cuff(playerid, params[]) { if(gTeam[playerid] == LSPD) { new targetid; if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, 0xFF00FF, "USAGE: /cuff (PlayerID)"); if(IsPlayerConnected(targetid)) { new Float:x, Float:y, Float:z; GetPlayerPos(targetid, x, y, z); if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) { if(gTeam[playerid] != LSPD) { if(IsCuffed[targetid] == false) { new string[64+MAX_PLAYER_NAME] new targetname[MAX_PLAYER_NAME] new playername[MAX_PLAYER_NAME] GetPlayerName(playerid, playername, sizeof(playername) format(string, sizeof(string), "You have been cuffed by officer %s",playername)); SendClientMessage(targetid, 0x0000FF, string); GetPlayerName(targetid, targetname, sizeof(targetname)) format(string, sizeof(string), "You have cuffed %s ", targetname)) SendClientMessage(playerid, 0xCCFF00, string)); SetPlayerAttachedObject(targetid,8,19418,6,-0.031999,0.024000,-0.024000,-7.900000,-32.000011,-72.299987,1.115998,1.322000,1.406000); SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED); IsCuffed = true; return 1; } else if(IsCuffed == true) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: This player is already cuffed!"); return 1; } return 1; } else if(gTeam[playerid] == LSPD) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: you can't cuff a law enforcer!"); return 1; { return 1; } else if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: That player is too far away from you!"); return 1; } return 1; } else if(!IsPlayerConnected(targetid)) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: Invalid ID!"); return 1! } return 1; } else if(gTeam[playerid] != LSPD) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: Only cops and use this command!"); return 1; } return 1; } Код:
CMD:uncuff(playerid, params[]) { if(gTeam[playerid] == LSPD) { new targetid; if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, 0xFF00FF, "USAGE: /uncuff (PlayerID)"); if(IsPlayerConnected(targetid)) { new Float:x, Float:y, Float:z; GetPlayerPos(targetid, x, y, z); if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) { if(gTeam[playerid] != LSPD) { if(IsCuffed[targetid] == true) { new string[64+MAX_PLAYER_NAME] new targetname[MAX_PLAYER_NAME] new playername[MAX_PLAYER_NAME] GetPlayerName(playerid, playername, sizeof(playername) format(string, sizeof(string), "You have been uncuffed by officer %s",playername)); SendClientMessage(targetid, 0x0000FF, string); GetPlayerName(targetid, targetname, sizeof(targetname)) format(string, sizeof(string), "You have uncuffed %s ", targetname)) SendClientMessage(playerid, 0xCCFF00, string)); if(IsPlayerAttachedObjectSlotUsed(targetid, 8)) { RemovePlayerAttachedObject(targetid, 8); return 1; } SetPlayerSpecialAction(targetid, SPECIAL_ACTION_NONE); IsCuffed = false; return 1; } else if(IsCuffed == true) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: This player is not cuffed!"); return 1; } return 1; } else if(gTeam[playerid] == LSPD) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: you can't use this on a law enforcer!"); return 1; { return 1; } else if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: That player is too far away from you!"); return 1; } return 1; } else if(!IsPlayerConnected(targetid)) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: Invalid ID!"); return 1! } return 1; } else if(gTeam[playerid] != LSPD) { SendClientMessage(playerid, 0xFF0000, "[ERROR]: Only cops and use this command!"); return 1; } return 1; } |
First of all you have to download ZCMD - include from here: https://sampforum.blast.hk/showthread.php?tid=91354
Then you have to include in your script: PHP код:
by the way if you downloaded the zcmd and putted it in Pawno>includes>zcmd.inc folder so just include it in your script as i have gave an example up, then when you gonna make a command so it would be like that: PHP код:
NOTE: You can use: PHP код:
|
thanks,
also, if I were to use 'IsPlayerAdmin' and else/if statements, how would I put it in 'CMD://cmd' is it the same way as 'OnPlayerCommand'? |
CMD:admin(playerid,params[])
{
if(IsPlayerAdmin(playerid)
{
SendClientMessageToAll(0xf8f8f8fff,"he is an admin");
}
else
{
SendClientMessage(playerid,0xf8f8f8888,"You aren't an RCON Admin to access to this shit");
}
return 1;
}
thanks,
also, if I were to use 'IsPlayerAdmin' and else/if statements, how would I put it in 'CMD://cmd' is it the same way as 'OnPlayerCommand'? |
//layout 1
CMD:exit(playerid){
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000, "[ERROR]: You are not authorized to use this command");
SendRconCommand("exit");
return 1;
}
//layout 2
CMD:exit(playerid){
if(IsPlayerAdmin(playerid)){
SendRconCommand("exit");
}
else SendClientMessage(playerid, 0xFF0000, "[ERROR]: You are not authorized to use this command");
return 1;
}