Help! Spawning. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help! Spawning. (
/showthread.php?tid=216913)
Help! Spawning. -
Tomejus - 26.01.2011
hello everyone!
I have a little but a big problem with spawning, somehow sometimes player cordinates set 0,0 and he's spawning at village (country) and i have this bug about month try'ed fix it alot of varietes but nothing helped me, it's a weird because it happens sometimes and I can't understand why:
Everything looks like :
Код:
public OnPlayerRequestSpawn(playerid)
{
if(IsPlayerNPC(playerid)) return 1;
if(!pInfo[playerid][Logged])
{
SendClientMessage(playerid, WHITE, "[ > ]{FF7E7E} First you have to log in.");
return 0;
}
if(pInfo[playerid][killed] == true)
{
SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), 2303.7888,-1195.8857,-18.0089, 0, 0, 0, 0, 0, 0, 0); // Ligoninл
pInfo[playerid][killed] = false;
return true;
}
if(playerDB[playerid][klaikas] <= 0)
{
new
fetch[ 256 ],
Float:pos[ 3 ];
format(query, 256, "SELECT * FROM `"TABLENAME"` WHERE id = '%i'", pInfo[playerid][pId]);
mysql_query(query);
mysql_store_result();
mysql_retrieve_row();
mysql_fetch_field_row(fetch,"pos_X");
pos[0] = floatstr(fetch);
mysql_fetch_field_row(fetch,"pos_Y");
pos[1] = floatstr(fetch);
mysql_fetch_field_row(fetch,"pos_Z");
pos[2] = floatstr(fetch);
mysql_fetch_field_row(fetch,"Interior");
SetPlayerInterior(playerid, strval(fetch));
SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), pos[ 0 ], pos[ 1 ], pos[ 2 ], 0, 0, 0, 0, 0, 0, 0); // Spawn
mysql_free_result();
}
return 1;
}
The 'klaikas' variable is jail variable it's that is player is not in the jail.
OnPlayerDisconnect i'm saving the player's information:
Код:
public OnPlayerDisconnect(playerid, reason)
{
SavePlayer(playerid);
if(playerDB[playerid][tsaugota] != INVALID_VEHICLE_ID)
{
SaveVehicle(playerid);
DestroyVehicle(playerDB[playerid][tsaugota]);
}
if(playerDB[playerid][tsaugota1] != INVALID_VEHICLE_ID)
{
SaveVehiclet(playerid);
DestroyVehicle(playerDB[playerid][tsaugota1]);
}
if(playerDB[playerid][aruzdetas]) Delete3DTextLabel(atekstas[playerid]);
if(playerDB[playerid][varuzdetas]) Delete3DTextLabel(vtekstas[playerid]);
new Float:zHealth;
GetPlayerHealth(playerid, zHealth);
if(zHealth <= 0)
{
AC_ResetPlayerWeapons(playerid);
playerDB[playerid][narkotikai] = 0;
SetPlayerPos(playerid, -2645.6074, 697.1324, 27.9375);
}
return 1;
}
And the saving:
Код:
stock SavePlayer(playerid)
{
if(pInfo[playerid][Logged])
{
new pName[ MAX_PLAYER_NAME ], file [ 50 ];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
new Float:pos[ 3 ];
if(Spawned[playerid])
{
GetPlayerPos(playerid, pos[ 0 ],pos[ 1 ],pos[ 2 ]);
format(query, 256, "UPDATE `"TABLENAME"` SET `Interior` = '%i', `pos_X` = '%f', `pos_Y` = '%f', `pos_Z` = '%f' WHERE (`id` = '%i')",\
GetPlayerInterior(playerid),pos[ 0 ],pos[ 1 ],pos[ 2 ],pInfo[playerid][pId]);
mysql_query(query);
}
It's not full code of saving only spawn, so } is missing, don't look at that. So, i understand why it hapens.
PLEASE HELP ME! I'm in stress now, because it's bug annoying me about month i try'd to ******, to do Spawn at OnPlayerSpawn callback, tryd other variables set but nothing helps me, help me people!
Re: Help! Spawning. -
Tomejus - 27.01.2011
Anyone? : /