String returning a weird value
#1

Hey folks!

I have a problem with an unban command, the string keeps returning a weird value.

PHP код:
CMD:unban(playerid,params[])
{
    new 
query[126];
    new 
usertounban[24];
    if(
sscanf(params"u[24]"usertounban)) return SendClientMessage(playerid,-1,"{FF0000}__**ERROR**__ {FFFFFF}Usage /Unban <Username>");
    if(
PlayerInfo[playerid][pAdmin] < 5) return SendClientMessage(playerid, -1"{FF0000}__**ERROR**__ {FFFFFF} You are not authorized to use that command!");
    
format(querysizeof(query), "SELECT * FROM 'BannedAccounts' WHERE 'UserName' = %s "usertounban);
    
mysql_tquery(mysqlquery,"CheckBan","d",playerid); 
    
printf("%s",query);
    
printf("%s",usertounban);
    print(
"CMD:unban -- properly executed");
    return 
1;

As you can see above, I'm telling the console to output the string value, and it returns this weird character: я
No matter what name I type in the command, it keeps returning the same value
I know this is a easy to solve problem but I can't figure it out!

Thanks for your help
-Milito
Reply
#2

What I would actually do, instead of u[24], use a s[24] and check to see if that string is an actual account or whatever, that actually might be your problem cause I don't really see nothing wrong with it.
Reply
#3

The problem is what The_ exactly said, you are using the incorrect sscanf specifier.
It should be s[24], u[24] is not right!
Reply
#4

Quote:
Originally Posted by The__
Посмотреть сообщение
What I would actually do, instead of u[24], use a s[24] and check to see if that string is an actual account or whatever, that actually might be your problem cause I don't really see nothing wrong with it.
Oh thanks guys
Problem solved
Reply
#5

Now, I got another problem....

The callback is not getting called.

I don't see anything wrong.

PHP код:
public CheckBan(playerid)
{
    print(
"CheckBan is working");
    if(
cache_num_rows() >=1)
    {
        
SendClientMessage(playerid,-1,"{FF0000}__**INFO**__ {FFFFFF} Username found, now you should finish the code!");
    }
    else
    {
        
SendClientMessage(playerid,-1,"{FF0000}__**ERROR**__ {FFFFFF} Username not found in our database!");
    }
    return 
1;

Reply
#6

You are using the incorrect MySQL query syntax in your /unban command. In other words, table and column names must be enclosed in grave accents (`), not singular quotes.

Try:

pawn Код:
SELECT * FROM `BannedAccounts` WHERE `UserName` = %s
Reply
#7

Quote:
Originally Posted by Emmet_
Посмотреть сообщение
You are using the incorrect MySQL query syntax in your /unban command. In other words, table and column names must be enclosed in grave accents (`), not singular quotes.

Try:

pawn Код:
SELECT * FROM `BannedAccounts` WHERE `UserName` = %s
I'm not quite sure, but I think the %s should be enclosed between ' ' aswell. Just like this:

pawn Код:
SELECT * FROM `BannedAccounts` WHERE `UserName` = '%s'
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)