COMMAND Problem
#1

Hey,

I have a problem,
all commands which are like:
/sendcash
/setlevel
/rob
/ban
/kick
/takemoney

Well all which you put an Id inside,
they don't work,
If you make /setlevel 1 1
it says just /setlevel (id) (level)
such as on /rob and other commands.

I had the problem sometime, and I think a include or plugin is needen idk.
I have dcmd on my GM!
Reply
#2

Anybody there to help?
Reply
#3

show us your code and new 0.3.7 makes use of zcmd
Reply
#4

Quote:
Originally Posted by DetoNater
Посмотреть сообщение
show us your code and new 0.3.7 makes use of zcmd
Heres an example:

PHP код:
CMD:rob(playerid,params[])
{
    new 
string[128];
    new 
ID;
    if(
sscanf(params"u"ID))
    {
        
SendClientMessage(playerid,COLOR_ERROR,"USAGE: /rob (Player Name/ID)");
        return 
1;
    }
    if(
IsSpawned[playerid] != 1)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to be able to use this command.");
        return 
1;
    }
    if(
IsFrozen[playerid] == 1)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You have been frozen by a Server Administrator. You cannot use this command.");
        return 
1;
    }
    if(
InAdminMode[ID] == 1)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You cannot use this command on this player because they are in Administrator mode.");
        return 
1;
    }
    if(
IsKidnapped[playerid] == 1)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You are kidnapped. You cannot use this command.");
        return 
1;
    }
    if(
gTeam[playerid] != TEAM_THIEF)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"Only thieves can rob players of their money.");
        return 
1;
    }
    if(!
IsPlayerConnected(ID))
    {
        
format(string,sizeof(string),"The player ID (%d) is not connected to the server. You cannot rob them",ID);
        
SendClientMessage(playerid,COLOR_ERROR,string);
        return 
1;
    }
    if(
GetDistanceBetweenPlayers(playerid,ID) > 4)
    {
        
format(string,sizeof(string),"%s(%d) is too far away. You cannot reach him to rob him.",PlayerName(ID),ID);
        
SendClientMessage(playerid,COLOR_ERROR,string);
        return 
1;
    }
    if(
GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You cannot rob someone while in a vehicle. Exit the vehicle first.");
        return 
1;
    }
    if(
GetPlayerState(ID) == PLAYER_STATE_DRIVER || GetPlayerState(ID) == PLAYER_STATE_PASSENGER)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You cannot rob someone while they are in a vehicle. Get them to exit the vehicle first.");
        return 
1;
    }
    if(
playerid == ID)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You cannot rob yourself, how can you even manage that?");
        return 
1;
    }
    if(
IsSpawned[ID] != 1)
    {
        
format(string,sizeof(string),"%s(%d) is not spawned. You cannot rob dead people ..",PlayerName(ID),ID);
        
SendClientMessage(playerid,COLOR_ERROR,string);
        return 
1;
    }
    if(
IsFrozen[ID] == 1)
    {
        
format(string,sizeof(string),"%s(%d) is frozen by a Server Administrator. You cannot rob them.",PlayerName(ID),ID);
        
SendClientMessage(playerid,COLOR_ERROR,string);
        return 
1;
    }
    if(
AttemptedToRobRecently[playerid] >= 1)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You are too tired from your last rob attempt. Please wait before robbing again.");
        return 
1;
    }
    if(
HasRobbedRecently[playerid] >= 1)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You are too tired from the last person you robbed. Please wait before robbing again.");
        return 
1;
    }
    if(
GetPlayerMoney(ID) <= 0)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"That player has no money in their pockets. What would be the point in robbing them?");
        return 
1;
    }
    new 
crand random(100);
    if(
crand <= 30)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"Rob attempt failed. The player slipped out of your grasp.");
        
AttemptedToRobRecently[playerid] =35;
        return 
1;
    }
    if(
GetDistanceBetweenPlayers(playerid,ID) <= && crand 30)
    {
        new 
current_zone player_zone[playerid];
        new 
mrand =random(GetPlayerMoney(ID));
        
SendClientMessage(playerid,COLOR_DEADCONNECT,"[[_Player Robbed_]]");
        
format(string,sizeof(string),"You have robbed $%d from %s(%d). Careful they dont come after you!",mrand,PlayerName(ID),ID);
        
SendClientMessage(playerid,COLOR_RED,string);
        
GivePlayerMoney(playerid,mrand);
        
IncreaseWantedLevel(playerid,8);
        
HasRobbedRecently[playerid] =180;
        
IncreasePlayerScore(playerid,3);
        
SendClientMessage(ID,COLOR_DEADCONNECT,"[[_Robbed_]]");
        
format(string,sizeof(string),"You have had $%d robbed from you by %s(%d). Kill them for your money back or run!",mrand,PlayerName(playerid),playerid);
        
SendClientMessage(ID,COLOR_RED,string);
        
GivePlayerMoney(ID,-mrand);
        
format(string,sizeof(string),"[POLICE RADIO] Robbery: %s(%d) has robbed $%d from %s(%d). Location: %s.",PlayerName(playerid),playerid,mrand,PlayerName(ID),ID,zones[current_zone][zone_name]);
        
SendClientMessageToAllCops(string);
        return 
1;
    }
    return 
1;

I made it in zcmd,
but I thing its not the problem of the code, but the problem of any include or plugin.
Reply
#5

It's because the if(sscanf only performs the functions in the brackets under it, it should be
Код:
if(sscanf(params, "u", ID)) return SendClientMessage(playerid,COLOR_ERROR,"USAGE: /rob (Player Name/ID)");
instead of
Код:
if(sscanf(params, "u", ID)) 
    { 
        SendClientMessage(playerid,COLOR_ERROR,"USAGE: /rob (Player Name/ID)"); 
        return 1; 
    }
Also you coulr use
Код:
if(variable1 == 0) return SendClientMessage(.....
to reduce the amount of lines in a command
Reply
#6

Quote:
Originally Posted by JaydenJason
Посмотреть сообщение
It's because the if(sscanf only performs the functions in the brackets under it, it should be
Код:
if(sscanf(params, "u", ID)) return SendClientMessage(playerid,COLOR_ERROR,"USAGE: /rob (Player Name/ID)");
instead of
Код:
if(sscanf(params, "u", ID)) 
    { 
        SendClientMessage(playerid,COLOR_ERROR,"USAGE: /rob (Player Name/ID)"); 
        return 1; 
    }
Also you coulr use
Код:
if(variable1 == 0) return SendClientMessage(.....
to reduce the amount of lines in a command
I didn't understand well how to add it on my script.
Reply
#7

Quote:
Originally Posted by JaydenJason
Посмотреть сообщение
It's because the if(sscanf only performs the functions in the brackets under it, it should be
Код:
if(sscanf(params, "u", ID)) return SendClientMessage(playerid,COLOR_ERROR,"USAGE: /rob (Player Name/ID)");
instead of
Код:
if(sscanf(params, "u", ID)) 
    { 
        SendClientMessage(playerid,COLOR_ERROR,"USAGE: /rob (Player Name/ID)"); 
        return 1; 
    }
It's exactly the same thing, no difference whatsoever.

@FrankLucretti: Is your plugin updated? I'm asking you because I've seen many people still use the version for 0.3d
Reply
#8

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
It's exactly the same thing, no difference whatsoever.

@FrankLucretti: Is your plugin updated? I'm asking you because I've seen many people still use the version for 0.3d
I don't know,
I have this one: https://sampforum.blast.hk/showthread.php?tid=91354
Reply
#9

I was referring to sscanf plugin.
Reply
#10

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
I was referring to sscanf plugin.
Still not working :/
but im sure it has something to do with a file.
Cause I had the problem sometime, and when I put a file inside it worked, but idk which file it was.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)