Problems when Spawning player - 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)
+--- Thread: Problems when Spawning player (
/showthread.php?tid=420861)
Problems when Spawning player -
Schartey - 07.03.2013
Hey people!
I've got a strange problem.
I've got a function to spawn my objects. Those are stored in a MySQL Database.
It actually works very well.
But somehow when the count of objects is more than 59 I get problems with my player spawn.
Somehow my SetSpawnInfo and SpawnPlayer function won't work anymore.
If I spawn less den 60 objects my script works just as I want.
Код:
public AddObjects() {
new string[256] = "SELECT * FROM objects";
mysql_query(string);
mysql_store_result();
while(mysql_fetch_row(string)) {
new dest[50][30];
split(string, dest);
printf("Adding Object ID: %s", dest[0]);
CreateObject(strval(dest[1]), floatstr(dest[3]), floatstr(dest[4]), floatstr(dest[5]), floatstr(dest[6]), floatstr(dest[7]), floatstr(dest[8]));
}
mysql_free_result();
}
Maybe you could help me.
Thx
Re: Problems when Spawning player -
RajatPawar - 07.03.2013
There's actually seemingly no problem here. Plus, I would recommend you to use R7 plugin using threaded queries ! Without all of this split and fetch row, you could create them in your callback. Anyways, can you share the OnPlayerSpawn code?
AW: Problems when Spawning player -
Schartey - 07.03.2013
Thx I will have a look at the R7 plugin, I'm new to SA-MP and used the first I found.
Well there isn't much in that callback and I can't think of anything that could have to do with my problem.
Код:
public OnPlayerSpawn(playerid)
{
if(PlayerInfo[playerid][pLogged] != 1 && PlayerInfo[playerid][pTut] != 1) {
SendClientMessage(playerid, COLOR_RED, "You must login!");
Kick(playerid);
} else if(PlayerInfo[playerid][pTut] == 1) {
TogglePlayerControllable(playerid, 0);
showTutorial(playerid);
tuttimer = SetTimerEx("showTutorial", 5000, true, "i",playerid);
} else {
TogglePlayerControllable(playerid, 1);
}
return 1;
}
Edit:
I've found a solution for my problem!
It seems like it takes some time to spawn the objects at the client. So it seems like I have to wait until I show the Login Dialog. Currently I have a timer which waits 2 seconds until showing the dialog and then everything works fine.