Spawn Player in House MYSQL
#3

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


Messages In This Thread
Spawn Player in House MYSQL - by BruLaX - 25.08.2013, 00:52
Re: Spawn Player in House MYSQL - by xXSPRITEXx - 25.08.2013, 01:20
Re: Spawn Player in House MYSQL - by [HiC]TheKiller - 25.08.2013, 01:40

Forum Jump:


Users browsing this thread: 1 Guest(s)