SA-MP Forums Archive
sscanf not allowing commands to work - 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: sscanf not allowing commands to work (/showthread.php?tid=554052)



sscanf not allowing commands to work - guitardude01 - 02.01.2015

Well, I made a admin system using sscanf and zcmd, but it keeps sending SERVER: Unknown command. We have a return for Server Unknown Command, but this isnt the problem. It sends Player Is not connected, but when we enter a VALID playerid, it says SERVER unknown command. Yet our little test command CMD:debug, works fine!

Any suggestions.

Heres the /makeadmin code, and the /debug code.

This code doesnt work
PHP код:
CMD:makeadmin(playeridparams[])
{
    new 
playerbstring[256], string1[256], level;
    if(
pInfo[playerid][Admin] < && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1"IT NO WORK FFS");
    if (
sscanf(params"ui"playerblevel)) return SendClientMessage(playerid, -1"Usage: /makeadmin [Playerid/part of name] [Level]");
    if(!
IsPlayerConnected(playerb)) return SendClientMessage(playeridCOL_ERROR"ERROR: That player is not connected!");
    if(
level && level 1337) return SendClientMessage(playeridCOL_ERROR"ERROR: Invalid level(Use level 1-4)");
    
pInfo[playerb][Admin] = level;
    
format(stringsizeof(string), "You have made %s a level %i Admin!"GetName(playerb), level);
    
SendClientMessage(playeridCOL_HELPERstring);
    
format(string1sizeof(string1), "%s has made you a level %i Admin!"GetName(playerid), level);
    
SendClientMessage(playerbCOL_HELPERstring1);
//    mysql_format(mysql, query, sizeof(query), "UPDATE `users` SET `Admin`=%d WHERE `id`=%d", pInfo[playerb][pAdmim], pInfo[playerb][pID]);
//    mysql_tquery(mysql, query);
    
return 1;

Yet this does?
PHP код:
CMD:debug(playeridparams[])
{
    
SendClientMessage(playerid, -1"Test complete == DO YOU SEE THIS MESSAGE?!");
    return 
1;

The only conclusion I can gather is that its because the debug doesnt use sscanf?


Re: sscanf not allowing commands to work - Sledgehammer - 02.01.2015

pawn Код:
if(!sscanf(params, "ui", playerb, level))



Re: sscanf not allowing commands to work - Wizzy951 - 02.01.2015

Make sure the plugins in your server config file are alphabetically assembled.


Re: sscanf not allowing commands to work - ATGOggy - 02.01.2015

But what is this:
PHP код:
   if(level && level 1337) return SendClientMessage(playeridCOL_ERROR"ERROR: Invalid level(Use level 1-4)"); 



Re: sscanf not allowing commands to work - guitardude01 - 02.01.2015

Quote:
Originally Posted by Death1300
Посмотреть сообщение
pawn Код:
if(!sscanf(params, "ui", playerb, level))
Tried this, then Unknown Command doesnt even show.


Re: sscanf not allowing commands to work - guitardude01 - 02.01.2015

Quote:
Originally Posted by ATGOggy
Посмотреть сообщение
But what is this:
PHP код:
   if(level && level 1337) return SendClientMessage(playeridCOL_ERROR"ERROR: Invalid level(Use level 1-4)"); 
This is checking if the level you inputted to make the player that admin level is valid.


Re: sscanf not allowing commands to work - guitardude01 - 02.01.2015

Quote:
Originally Posted by Wizzy951
Посмотреть сообщение
Make sure the plugins in your server config file are alphabetically assembled.
Done, but this has not done anything.


AW: sscanf not allowing commands to work - CutX - 02.01.2015

the only line which could trigger the "unknown command" message
is this here:
pawn Код:
pInfo[playerb][Admin] = level;
for example, accessing an invalid element triggers a run time error
for security reasons. we aint allowed to access memory that
id not within the memory region pawn is using.
Cuz if we could, we'd be abel to screw with server variables on linux servers for example.

as for this case here, check "pInfo"
make sure that everything's been declared correctly.


Re: AW: sscanf not allowing commands to work - guitardude01 - 02.01.2015

Quote:
Originally Posted by CutX
Посмотреть сообщение
the only line which could trigger the "unknown command" message
is this here:
pawn Код:
pInfo[playerb][Admin] = level;
for example, accessing an invalid element triggers a run time error
for security reasons. we aint allowed to access memory that
id not within the memory region pawn is using.
Cuz if we could, we'd be abel to screw with server variables on linux servers for example.

as for this case here, check "pInfo"
make sure that everything's been declared correctly.
Here is my enum for pInfo, not sure whats wrong with it?
PHP код:
enum PDATA
{
    
Username[32],
    
Password[129], 
    
Admin
    
Helper,
    
Money 
}
new 
pInfo[MAX_PLAYERS][PDATA]; 



AW: Re: AW: sscanf not allowing commands to work - CutX - 02.01.2015

Quote:
Originally Posted by guitardude01
Посмотреть сообщение
Here is my enum for pInfo, not sure whats wrong with it?
PHP код:
enum PDATA
{
    
Username[32],
    
Password[129], 
    
Admin
    
Helper,
    
Money 
}
new 
pInfo[MAX_PLAYERS][PDATA]; 
seems legid.

so it must be something wrong with the 1st index
what if "playerb" contains a value that cannot be used as index?
usage defined by you:
Quote:
Originally Posted by OP
Usage: /makeadmin [Playerid/part of name] [Level]
so "playerb" is "Playerid/part of name"

why not try "dd" instead of "ui"

pawn Код:
if (sscanf(params, "dd", playerb, level)) return SendClientMessage(playerid, -1, "Usage: /makeadmin [Playerid] [Level]");
i assure you, this will work