Saving team help
#1

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?
Reply
#2

AssignPlayerData must be called on mysql_tquery. Have you done that?
Reply
#3

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);
            }
Reply
#4

put it in onplayerspawn

Quote:

SetPlayerTeam(playerid,Player[playerid][PlayerTeam]);

Reply
#5

Quote:
Originally Posted by Tenka
Посмотреть сообщение
put it in onplayerspawn
Already did. Doesn't work.
Reply
#6

What does PlayerTeam saves?.
ID? OR the Class Name? Print a debug for PlayerTeam...
Reply
#7

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.
Reply
#8

Please print Player[playerid][PlayerTeam]; . Lets see if you choose the class team number. if it right.
Reply
#9

Where i should put the print and how to?
Reply
#10

Код:
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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)