Closed nexquery closed 9 months ago
Repro steps?
public OnPlayerConnect(playerid)
{
TogglePlayerSpectating(playerid, true);
return 1;
}
new fmt[64], hesapid;
mysql_format(gSQL, fmt, sizeof(fmt), "SELECT * FROM karakterler WHERE id = %d;", hesapid);
mysql_tquery(gSQL, fmt, "Karakter_Yukle", "d", playerid);
Load character data from the callback and use the codes below.
callback::Karakter_Yukle(playerid)
{
if(cache_num_rows())
{
new
Float:x,
Float:y,
Float:z,
Float:a
;
cache_get_value_name_float(0, "px", x);
cache_get_value_name_float(0, "py", y);
cache_get_value_name_float(0, "pz", z);
cache_get_value_name_float(0, "pa", a);
cache_get_value_name_int(0, "skin", Karakter[playerid][karakter_skin]);
TogglePlayerSpectating(playerid, false);
SetSpawnInfo(playerid, NO_TEAM, Karakter[playerid][karakter_skin], x, y, z, a, WEAPON_FIST, 0, WEAPON_FIST, 0, WEAPON_FIST, 0);
SpawnPlayer(playerid);
}
return 1;
}
Toggling spectating off already implicitly spawns the player, an extra call to SpawnPlayer
should not be necessary. The SetSpawnInfo
call should probably occur before the player actually spawns, so before spectating is toggled off.
@nexquery close
callback::Karakter_Yukle(playerid)
{
if(cache_num_rows())
{
new
Float:x,
Float:y,
Float:z,
Float:a
;
cache_get_value_name_float(0, "px", x);
cache_get_value_name_float(0, "py", y);
cache_get_value_name_float(0, "pz", z);
cache_get_value_name_float(0, "pa", a);
cache_get_value_name_int(0, "skin", Karakter[playerid][karakter_skin]);
SetSpawnInfo(playerid, NO_TEAM, Karakter[playerid][karakter_skin], x, y, z, a, WEAPON_FIST, 0, WEAPON_FIST, 0, WEAPON_FIST, 0);
TogglePlayerSpectating(playerid, false);
}
return 1;
}
I edited the codes as you said, I will test it for a while since the problem does not always occur, if it persists I will write again.
@nexquery Close if you done with testing
If you try to use a skin added with AddCharModel, you will sometimes spawn with the CJ skin. But this is not always the case. To solve this problem, you need to reuse the SetPlayerSkin function.