PDA

View Full Version : Class resets to Cop?


vassilis
20/01/2015, 09:18 PM
solved

nezo2001
20/01/2015, 09:26 PM
I don't know working with mysql but in y_ini you make this

When the player choose the skin do

pinfo[playerid][skin] = //skinid ;

OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid)); //We open the file "I don't know in mysql"
INI_WriteInt(File,"Skin",GetPlayerSkin(playerid)); //write in the file "In the database" in the skin colmun the last skin that the player was in it
INI_Close(File);
return 1;
}



OnPlayerSpawn(playerid)
{
SetPlayerSkin(playerid, pinfo[playerid][skin];
return 1;
}

vassilis
20/01/2015, 09:32 PM
I don't know working with mysql but in y_ini you make this

When the player choose the skin do

pinfo[playerid][skin] = //skinid ;

OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid)); //We open the file "I don't know in mysql"
INI_WriteInt(File,"Skin",GetPlayerSkin(playerid)); //write in the file "In the database" in the skin colmun the last skin that the player was in it
INI_Close(File);
return 1;
}



OnPlayerSpawn(playerid)
{
SetPlayerSkin(playerid, pinfo[playerid][skin];
return 1;
}


You don't really help iask with MySQL since i use mysql but thanks..

nezo2001
20/01/2015, 09:35 PM
All the problem to save and load and i think you can convert from y_ini to mysql

vassilis
20/01/2015, 09:49 PM
I need someone with MySQL Knowledge to help me :/

vassilis
21/01/2015, 08:52 PM
still unsolved lol

Ironboy
21/01/2015, 09:16 PM
Give it a try
case dialog_login:
{
if( response )
{
new pPass[ 20 ];
if( sscanf( inputtext, "s[20]", pPass ) )
{
SendClientMessage(playerid,-1,""COL_RED"CCNR SYSTEM"COL_WHITE": Our system requires to "COL_GREEN"login"COL_WHITE"to continue.");
Kick(playerid);
return 1;
}
OnPlayerLogin2( playerid, pPass );
if(recentlyregistered[playerid] != 1)
{
mysql_format(MySQLTunnel, Query, sizeof(Query), "SELECT `pskin`, `pteam` FROM `accounts` WHERE `pid` = '%d'", pinfo[playerid][pMySQLID]);
new Cache:result = mysql_query(MySQLTunnel, Query);
if(cache_get_row_count() != 0)
{
pinfo[playerid][Skin] = cache_get_field_content_int(0, "pskin");
pinfo[playerid][Team] = cache_get_field_content_int( 0, "pteam");
SetPlayerSkin(playerid,pinfo[playerid][Skin]);
}
cache_delete(result);
SetSpawnInfo(playerid, pinfo[playerid][Team], pinfo[playerid][Skin], 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}

}
return 1;
}

vassilis
21/01/2015, 10:39 PM
Give it a try
case dialog_login:
{
if( response )
{
new pPass[ 20 ];
if( sscanf( inputtext, "s[20]", pPass ) )
{
SendClientMessage(playerid,-1,""COL_RED"CCNR SYSTEM"COL_WHITE": Our system requires to "COL_GREEN"login"COL_WHITE"to continue.");
Kick(playerid);
return 1;
}
OnPlayerLogin2( playerid, pPass );
if(recentlyregistered[playerid] != 1)
{
mysql_format(MySQLTunnel, Query, sizeof(Query), "SELECT `pskin`, `pteam` FROM `accounts` WHERE `pid` = '%d'", pinfo[playerid][pMySQLID]);
new Cache:result = mysql_query(MySQLTunnel, Query);
if(cache_get_row_count() != 0)
{
pinfo[playerid][Skin] = cache_get_field_content_int(0, "pskin");
pinfo[playerid][Team] = cache_get_field_content_int( 0, "pteam");
SetPlayerSkin(playerid,pinfo[playerid][Skin]);
}
cache_delete(result);
SetSpawnInfo(playerid, pinfo[playerid][Team], pinfo[playerid][Skin], 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}

}
return 1;
}
Ok so i tried yours and i added the and printedf to check whats the problem i noticed that on print it says the correct skin and team (SKIN 292 TEAM 5(TEAM CIVILIAN) ) BUT i get spawned as cop...

Ironboy
22/01/2015, 12:04 PM
I guess recentlyregistered[playerid] turn to 1 once if someone register and i think you should place the team spawn inside of

if(recentlyregistered[playerid] == 1)
{
//here along with the sql update
}

NOTE : I am creating the accounts table when gamemodeinit opens(just for once of course) could this affect in a way the saving? Should i make the table of accounts manually?

Creating table when the gamemode starts doesn't cause any problems but manual creation recommended.

vassilis
22/01/2015, 07:27 PM
I guess recentlyregistered[playerid] turn to 1 once if someone register and i think you should place the team spawn inside of

if(recentlyregistered[playerid] == 1)
{
//here along with the sql update
}


Creating table when the gamemode starts doesn't cause any problems but manual creation recommended.

I noticed that when player registers it doesnt gives him the defualt money integer i have put($3000) but when he relogs so i guess its a problem with loading?

Ironboy
22/01/2015, 07:49 PM
I noticed that when player registers it doesnt gives him the defualt money integer i have put($3000) but when he relogs so i guess its a problem with loading?

It wont affect the loading part because you're just putting the teamspawn right inside the recentlyregistered as you want the players to spawn directly after they login without letting them to choose the skin or team. I suppose recentlyregistered would turn 1 only when a player register and set back to 0 when they disconnect i.e recentlyregistered turn 1 only one time for each player. That means when they spawn next time after login, they'd be getting the saved skin and team without any swapping of commands. Just give it a go, worth a shot.