SA-MP Forums Archive
sscanf2 error - 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: sscanf2 error (/showthread.php?tid=434696)



sscanf2 error - Tyrexo - 03.05.2013

Hi,i wanted to add a little sistem of voting sistem,but i'ts giving me this error and i don't know why?

Look:

pawn Код:
D:\Jocuri\Kituri\Server Samp\pawno\include\sscanf2.inc(199) : warning 219: local variable "name" shadows a variable at a preceding level
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Warning.

And this is the line from 199 in sscanf2 :

pawn Код:
name[MAX_PLAYER_NAME];
pawn Код:
{
        new
        name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof (name));
        SSCANF_Join(playerid, name, IsPlayerNPC(playerid));
        #if defined SSCANF_OnPlayerConnect
            SSCANF_OnPlayerConnect(playerid);
        #endif
        return 1;
    }



Re: sscanf2 error - MattyG - 03.05.2013

You must have declared name already, hit Ctrl + F and find it, then decide which one to use.


Re: sscanf2 error - Tanush123 - 03.05.2013

explain this part please?
pawn Код:
{
198        new
199        name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof (name));
        SSCANF_Join(playerid, name, IsPlayerNPC(playerid));
        #if defined SSCANF_OnPlayerConnect
            SSCANF_OnPlayerConnect(playerid);
        #endif
        return 1;
    }
or
pawn Код:
{
199        new
200        name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof (name));
        SSCANF_Join(playerid, name, IsPlayerNPC(playerid));
        #if defined SSCANF_OnPlayerConnect
            SSCANF_OnPlayerConnect(playerid);
        #endif
        return 1;
    }



Respuesta: sscanf2 error - Tyrexo - 03.05.2013

199 name[MAX_PLAYER_NAME];


Re : sscanf2 error - yusei - 03.05.2013

Try To rename a Variable [name]

PHP код:
{
        new
        
name2[MAX_PLAYER_NAME];
        
GetPlayerName(playerid, name2, sizeof (name2));
        
SSCANF_Join(playerid, name2, IsPlayerNPC(playerid));
        
#if defined SSCANF_OnPlayerConnect
            
SSCANF_OnPlayerConnect(playerid);
        
#endif
        
return 1;
    } 



Respuesta: sscanf2 error - Tyrexo - 03.05.2013

Worked,now i will try it in game,hehe,i'll come back if don't working.


Re: sscanf2 error - Tanush123 - 03.05.2013

Remove line 198 and 199, you probably have anyone variable somewhere.


Respuesta: sscanf2 error - Tyrexo - 03.05.2013

Not working in game,what to do now

in game i have to do this command /ask to do a vot but it's not working.

this is the sistem voting i have it : https://sampforum.blast.hk/showthread.php?tid=286403


Re: sscanf2 error - Areax - 03.05.2013

Hello!

Try this:

Add this 2 stocks somewhere in your script, but not in callback!

Stock 1:
PHP код:
stock GetName(playerid)
{
new
name[24];
GetPlayerName(playerid, name, sizeof(name));
return 
name;
} 
Stock 2:

PHP код:
stock SendAdminMessage(color, const string[])
{
    for(new 
i = 0; i < MAX_PLAYERS; i++)
    {
        if(
IsPlayerAdmin[i])
        
SendClientMessage(i, color, string);
    }
    return 
1;
} 
And here is the code for /ask command:

PHP код:
CMD:ask(playerid, params[])
{
    new 
question;
    new 
string[160];
    if(
sscanf(params, "s", question)) return SendClientMessage(playerid, -1, "Usage: /ask [question]");
    
format(string, sizeof(string), "[ASK]: New Question By: %s | Question: %s", GetName(playerid), question);
    
SendAdminMessage(-1, string);
    
SendClientMessage(playerid, -1, "[ASK]: Your Question Has Been Send To an Online Administrator");
    return 
1;
} 
Hope I helped you

Note: I didn't test yet...