Spawn Player in House MYSQL - 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: Spawn Player in House MYSQL (
/showthread.php?tid=459863)
Spawn Player in House MYSQL -
BruLaX - 25.08.2013
Hello i have a probleme i try to create the spawn player in house but i does only teleports it to house id 0 if hes the owner but if het aint the owner it stil go search for id 0 and not the other id's
Her the code sorry for my english
Код:
stock SpawnPlayerAtHouse(playerid)
{
new pname[24],QUERY[400],id;
GetPlayerName(playerid, pname, 24);
format(QUERY, sizeof(QUERY), "SELECT * FROM House WHERE Owner = '%s' AND id = %i",pname,id);
mysql_query(QUERY);
mysql_store_result();
while (mysql_retrieve_row())
{
SetPlayerPos(playerid, HouseInfo[id][hExitX], HouseInfo[id][hExitY], HouseInfo[id][hExitZ]);
SetPlayerInterior(playerid, HouseInfo[id][hInterior]);
SetPlayerVirtualWorld(playerid, id);
}
mysql_free_result();
}
Re: Spawn Player in House MYSQL -
xXSPRITEXx - 25.08.2013
Does the MySQL have the correct table in it?
Re: Spawn Player in House MYSQL -
[HiC]TheKiller - 25.08.2013
The variable id is not set to anything so it's going to return 0 every time. If the houses actually correspond to the ids in the database, then you can do something like:
pawn Код:
stock SpawnPlayerAtHouse(playerid)
{
new pname[24],QUERY[400],id;
GetPlayerName(playerid, pname, 24);
format(QUERY, sizeof(QUERY), "SELECT id FROM House WHERE Owner = '%s' LIMIT 1",pname);
mysql_query(QUERY);
mysql_store_result();
id = mysql_fetch_int();
SetPlayerPos(playerid, HouseInfo[id][hExitX], HouseInfo[id][hExitY], HouseInfo[id][hExitZ]);
SetPlayerInterior(playerid, HouseInfo[id][hInterior]);
SetPlayerVirtualWorld(playerid, id); //You may want to change this. If the house id is 0, then it will go into the normal world.
mysql_free_result();
}