Out of curiosity..
#1

SEE BOTTOM POST

Why does the PVar return 0 on this?

pawn Code:
sscanf(line, "p|sssdd", username[24], password[15], ip[50], skin[3], factionid[2]);
SetPVarInt(playerid, "Skin", skin[3]);
In phpadmin the field is set to INT and is 11 characters long. (I know it shouldn't be, but even if I lower it or raise it the problem still occurs)

EDIT: I've also tried removing the arrays, for example:

pawn Code:
sscanf(line, "p|sssdd", username, password, ip, skin, factionid);
SetPVarInt(playerid, "Skin", skin);
This still, returns 0.
Reply
#2

Do you get any errors or warnings when you compile? If not, what about anything in your server_log.txt file? Maybe mysql_log.txt...
Reply
#3

Are you using sscanf 2.0 or the regular one?

If you are using 2.0, you need to use p delimiter.
pawn Code:
sscanf(line, "p<|>s[24]s[24]s[16]dd", username, password, ip, skin, factionid); // Try using arrays with strings if you are using 2.0...
Reply
#4

Yes I'm using 2.0. (Plugin, obviously)

I now have this:

pawn Code:
new username, password, ip, skin, factionid;

sscanf(line, "p<|>s[24]s[15]s[50]dd", username, password, ip, skin, factionid);

SetPVarInt(playerid, "Skin", skin);
And yet it is still setting me to CJ, in the table this is what is there:

Quote:

Lewwy
mypassword
127.0.0.1
2
1

Quote:

Username: VARCHAR 24
Password: VARCHAR 15
IP: VARCHAR 50
Skin: INT 11
Faction: INT 11

Reply
#5

Quote:
Originally Posted by Lewwy
View Post
Yes I'm using 2.0. (Plugin, obviously)

I now have this:

pawn Code:
new username, password, ip, skin, factionid;

sscanf(line, "p<|>s[24]s[15]s[50]dd", username, password, ip, skin, factionid);

SetPVarInt(playerid, "Skin", skin);
And yet it is still setting me to CJ, in the table this is what is there:
Heres another thing...I'm guessing this sscanf line is in OnPlayerLogin or something?

Try adding something like this under OnPlayerSpawn.
pawn Code:
GetPVarInt(playerid, "Skin");
SetPlayerSkin(playerid, Skin);
if that doesn't work, try assigning a var to GetPVarInt (Sounds stupid I know).
I.e
new SetSkin = GetPVarInt(playerid, "Skin");
SetPlayerSkin(playerid, SetSkin);
Reply
#6

Well, I'm slightly confused.

Faction doesn't work either, that always returns 0. To prove this, I have this code:

pawn Code:
if(GetPVarInt(playerid, "Faction") != 1) return ShowPlayerDialog(playerid, FACTIONSPAWN, DIALOG_STYLE_MSGBOX, "Small Town America - Faction Spawn", "You are currently in a faction.\n\nWould you like to spawn at your faction's headquarters?", "Yes", "No");
And when I spawn, it always pops up with that dialog. Am I missing something out here? Is there another method? I've tried your method, and it doesn't seem to work.
Reply
#7

Sorry to bump, but a whole new error has occured. I now have this code OnPlayerLogin:

pawn Code:
sscanf(line, "p<|>s[24]s[15]s[50]dd", username, password, ip, skin, factionid);

SetPVarInt(playerid, "LoggedIn", 1);
SetPVarInt(playerid, "Skin", skin);
SetPVarInt(playerid, "Faction", factionid);
           
RealSpawn(playerid);
           
mysql_free_result();
After I enter my pass and the sscanf line is called, the server will hang and my connection to the server will be lost. In the MySQL logs the log ends at this moment:

Quote:

[19:23:35] >> mysql_query( Connection handle: 1 )
[19:23:35] CMySQLHandler::Query(SELECT * FROM `accounts` WHERE `username` = 'Lewwy') - Successfully executed.
[19:23:35] >> mysql_store_result( Connection handle: 1 )
[19:23:35] CMySQLHandler::StoreResult() - Result was stored.
[19:23:35] >> mysql_num_rows( Connection handle: 1 )
[19:23:35] CMySQLHandler::NumRows() - Returned 1 row(s)
[19:23:36] >> mysql_query( Connection handle: 1 )
[19:23:36] CMySQLHandler::Query(SELECT * FROM `accounts` WHERE `username` = 'Lewwy' AND `password` = 'password') - Successfully executed.
[19:23:36] >> mysql_store_result( Connection handle: 1 )
[19:23:36] CMySQLHandler::StoreResult() - Result was stored.
[19:23:36] >> mysql_num_rows( Connection handle: 1 )
[19:23:36] CMySQLHandler::NumRows() - Returned 1 row(s)
[19:23:36] >> mysql_fetch_row_format( Connection handle: 1 )
[19:23:36] CMySQLHandler::FetchRow() - Return: Lewwy|password|127.0.0.1|281|1

I have tried removing things after the sscanf line, and still no luck. It looks like something is going wrong while fetching the data from sscanf, it no longer has anything to do with the PVars. Any ideas?

EDIT: The real spawn code is just SpawnPlayer.
Reply
#8

Bump.. (12 hours)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)