Saving team help -
KinderClans - 07.08.2018
So,i created a system to save chosen player team. The team is saved without problems, but it doesn't set it when i relog.
I have an autospawn after the player logged in using SpawnPlayer(playerid);
This is AssignPlayerData query which loads account stats when player has been logged:
pawn Код:
AssignPlayerData(playerid)
{
cache_get_value_int(0, "id", Player[playerid][ID]);
cache_get_value_int(0, "PlayerTeam", Player[playerid][PlayerTeam]);
SetPlayerTeam(playerid,Player[playerid][PlayerTeam]);
return 1;
}
For saving team when player disconnects i use GetPlayerTeam which saves correctly the team id.
But if i relog, i get autospawned yes, but assigned to wrong team.
Example: I have 2 teams: Civilians/Cops, i choose Cops, so team id 1 (based on classid), team id 1 gets saved correctly on disconnect. When i relog and autospawn, i spawn as team 0 (civilian).
What's wrong?
Re: Saving team help -
zPain - 07.08.2018
AssignPlayerData must be called on
mysql_tquery. Have you done that?
Re: Saving team help -
KinderClans - 07.08.2018
Well no, AssignPlayerData is in the login dialog:
pawn Код:
if (strcmp(hashed_pass, Player[playerid][Password]) == 0)
{
cache_set_active(Player[playerid][Cache_ID]);
AssignPlayerData(playerid);
cache_delete(Player[playerid][Cache_ID]);
Player[playerid][Cache_ID] = MYSQL_INVALID_CACHE;
KillTimer(Player[playerid][LoginTimer]);
Player[playerid][LoginTimer] = 0;
Player[playerid][IsLoggedIn] = true;
new ggString[128];
format(ggString, sizeof(ggString), ""WHITE"* Welcome back "SAMP_BLUE"%s (%d) "WHITE"- "SAMP_BLUE"Account ID: %d "WHITE"- Your stats have been loaded.", ReturnPlayerName(playerid), playerid, Player[playerid][ID]);
SendClientMessage(playerid, -1, ggString);
SetSpawnInfo(playerid, Player[playerid][PlayerTeam], Player[playerid][Skin], 0, 0, 0, 0, 0, 0, 280, 0, 0, 0);
SpawnPlayer(playerid);
}
Re: Saving team help -
Tenka - 08.08.2018
put it in onplayerspawn
Quote:
SetPlayerTeam(playerid,Player[playerid][PlayerTeam]);
|
Re: Saving team help -
KinderClans - 08.08.2018
Quote:
Originally Posted by Tenka
put it in onplayerspawn
|
Already did. Doesn't work.
Re: Saving team help -
DerickClark - 08.08.2018
What does PlayerTeam saves
?.
ID? OR the Class Name? Print a debug for PlayerTeam...
Re: Saving team help -
KinderClans - 08.08.2018
This is how i load team:
When the player has logged in:
pawn Код:
SetSpawnInfo(playerid, Player[playerid][PlayerTeam], Player[playerid][Skin], 0, 0, 0, 0, 0, 0, 280, 0, 0, 0);
SpawnPlayer(playerid);
(I use SpawnPlayer for autologin to skip directly class selection).
And on OnPlayerSpawn i have this:
pawn Код:
SetPlayerTeam(playerid,Player[playerid][PlayerTeam]);
@DerickClark: I save the ID.
Re: Saving team help -
DerickClark - 08.08.2018
Please print Player[playerid][PlayerTeam]; . Lets see if you choose the class team number. if it right.
Re: Saving team help -
KinderClans - 08.08.2018
Where i should put the print and how to?
Re: Saving team help -
DerickClark - 08.08.2018
Код:
CMD:cteam(playerid, params[])
{
new string[90];
format(string, sizeof(string), "[TEAM]: Your team number is: %i", Player[playerid][PlayerTeam]);
SendClientMessage(playerid, -1, string);
return 1;
}