SA-MP Forums Archive
Help Please - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help Please (/showthread.php?tid=314229)



Help Please - Nuke547 - 29.01.2012

The script works, but when I do it, it sets whoever's id is 0.

PHP код:
command(givebadgeplayeridparams[])
{
    new 
idbadgestring[255];
    if(
sscanf(params"zz"idbadge))
    {
        if((
Player[playerid][Group] == || Player[playerid][Group] == 4) && Player[playerid][GroupRank] >= 7)
        {
            
SendClientMessage(playeridWHITE"SYNTAX: /givebadge [playerid] [badge]");
        }
    }
    else
    {
        if((
Player[playerid][Group] == || Player[playerid][Group] == 4) && Player[playerid][GroupRank] >= 7)
        {
            
Player[id][BadgeNumber] = badge;
            
format(stringsizeof(string), "You have given %s the badge number %s"GetName(id), badge);
            
SendClientMessage(playeridWHITEstring);
            
format(stringsizeof(string), "%s has changed your badge number to %s"GetName(playerid), badge);
            
SendClientMessage(idWHITEstring);
        }
    }




Re: Help Please - jamesbond007 - 29.01.2012

pawn Код:
command(givebadge, playerid, params[])
{
    new id, badge, string[255];
    if(!sscanf(params, "ds", id, badge))
    {
        if((Player[playerid][Group] == 1 || Player[playerid][Group] == 4) && Player[playerid][GroupRank] >= 7)
        {
            Player[id][BadgeNumber] = badge;
            format(string, sizeof(string), "You have given %s the badge number %s", GetName(id), badge);
            SendClientMessage(playerid, WHITE, string);
            format(string, sizeof(string), "%s has changed your badge number to %s", GetName(playerid), badge);
            SendClientMessage(id, WHITE, string);
        }
    }
    else return SendClientMessage(playerid, WHITE, "SYNTAX: /givebadge [playerid] [badge]");
}
try this...


Re: Help Please - Nuke547 - 29.01.2012

Quote:
Originally Posted by jamesbond007
Посмотреть сообщение
pawn Код:
command(givebadge, playerid, params[])
{
    new id, badge, string[255];
    if(!sscanf(params, "ds", id, badge))
    {
        if((Player[playerid][Group] == 1 || Player[playerid][Group] == 4) && Player[playerid][GroupRank] >= 7)
        {
            Player[id][BadgeNumber] = badge;
            format(string, sizeof(string), "You have given %s the badge number %s", GetName(id), badge);
            SendClientMessage(playerid, WHITE, string);
            format(string, sizeof(string), "%s has changed your badge number to %s", GetName(playerid), badge);
            SendClientMessage(id, WHITE, string);
        }
    }
    else return SendClientMessage(playerid, WHITE, "SYNTAX: /givebadge [playerid] [badge]");
}
try this...
It still happens. That didnt fix it


Re: Help Please - jamesbond007 - 29.01.2012

are you trying it on yourself / or a disconnected player?


Respuesta: Help Please - admantis - 29.01.2012

That is because the sscanf specieirs are not used correctly.
Use "u" for players.
And in format, are you using a string specifier for a integer? Is "badge" a string or a value? If it's a string do like this
pawn Код:
new badge[128];
if(!sscanf(params, "us[128]", id, badge))
As you can see, you also need to specify the string's size.


Re: Respuesta: Help Please - Nuke547 - 29.01.2012

Quote:
Originally Posted by admantis
Посмотреть сообщение
That is because the sscanf specieirs are not used correctly.
Use "u" for players.
And in format, are you using a string specifier for a integer? Is "badge" a string or a value? If it's a string do like this
pawn Код:
new badge[128];
if(!sscanf(params, "us[128]", id, badge))
As you can see, you also need to specify the string's size.
Im not sure. Its more of a string, but its basically gonna be like Your name Badge Number:

Could you please put it like i should put it in the script


Re: Respuesta: Help Please - Ballu Miaa - 29.01.2012

Quote:
Originally Posted by Nuke547
Посмотреть сообщение
Im not sure. Its more of a string, but its basically gonna be like Your name Badge Number:

Could you please put it like i should put it in the script
If its gonna be a number(integer) Then use i instead of us which is for a string!


Re: Respuesta: Help Please - Nuke547 - 29.01.2012

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
If its gonna be a number(integer) Then use i instead of us which is for a string!
Can you reply with what it is supposed to be? Its not working


Re: Help Please - Nuke547 - 29.01.2012

Bump