My cmd doesn't work?
#1

Hello,i'm having a problem with my /sethuman command on my script, it doesn't seem to actually set the playerid i'm trying to make it! anyone know how to fix this?

pawn Код:
if (strcmp("/sethuman", cmdtext, true) == 0)
{
    if(PlayerInfo[playerid][jAdmin] < 3) return SendClientMessage(playerid,0xFF0000AA,"ERROR: You are not allowed to use this command!");//Checking if the player has admin level 3, if not it sends him a message.
    new targetid;
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Player not connected!");
    else
    {
        format(string, sizeof(string), "%s has set you to human.", PlayerName(playerid));
        SendClientMessage(targetid, BLANCO, string);
        gTeam[targetid] = EHUMAN;
        HumanTeamCambia(targetid);
        PlayerInfo[targetid][jZombie] = 0;
        PlayerInfo[targetid][jInfected] = 0;
    }
    return 1;
}
Regards
Oscii
Reply
#2

Of course it won't.
You defined targetid, but didn't give it any value. So targetid contains junk, and when you perform the command on it nothing happens because it's not a valid player ID.
Use sscanf for commands with parameters.
Reply
#3

I don't know how to use sscanf with strcmp.. *cries*

Would you be able to help me put the sscanf into it? would help alot! :3
Reply
#4

Read this maybe it will help you:

https://sampforum.blast.hk/showthread.php?tid=300397
Reply
#5

The command in this topic isn't zcmd and I'm not planning on converting YET! :P
Reply
#6

https://sampforum.blast.hk/showthread.php?tid=310815
Reply
#7

Start using ZCMD its now or never.
pawn Код:
CMD:sethuman(playerid, params[])
{
    if(PlayerInfo[playerid][jAdmin] < 3) return SendClientMessage(playerid,0xFF0000AA,"ERROR: You are not allowed to use this command!");//Checking if the player has admin level 3, if not it sends him a message.
    new targetid;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, "{FF8000}/SetHuman {FF0000}[PlayerID/PartOfName]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Player not connected!");
    else
    {
        format(string, sizeof(string), "%s has set you to human.", PlayerName(playerid));
        SendClientMessage(targetid, BLANCO, string);
        gTeam[targetid] = EHUMAN;
        HumanTeamCambia(targetid);
        PlayerInfo[targetid][jZombie] = 0;
        PlayerInfo[targetid][jInfected] = 0;
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)