Help on OnPlayerSpawn, setting position
#1

I have this on OnPlayerSpawn. There is some problem that makes the player spawn out of the world boundries.

There's no log on MySQL, it looks like the script is calling the select function.

Any help here? Please?


pawn Код:
if(PVar[playerid][pSpawn]==0){
        new string[50];
        format(string, sizeof(string), "Retornando ao ponto inicial...");
        GameTextForPlayer(playerid, string, 3000, 4);
        SetPlayerPos(playerid,73.6155,-219.4525,1.5825);
    }
    else if(PVar[playerid][pSpawn]==1){
        if(Playerhashouse(playerid)){
            new
            Str[100],
            query[128],
            Float:bX,
            Float:bY,
            Float:bZ;
            format(query, sizeof(query), "SELECT `bX`,`bY`,`bZ` FROM `business` WHERE `Owner`='%s' AND type='1273'",pName(playerid));
            mysql_query(query);
            mysql_store_result();
            if(mysql_num_rows() > 0)
            {
                while(mysql_fetch_row(Str))
                {
                    sscanf(Str, "p<|>fff",bX,bY,bZ);
                    new string[50];
                    format(string, sizeof(string), "Retornando a sua casa...");
                    GameTextForPlayer(playerid, string, 3000, 4);
                    SetPlayerPos(playerid,bX,bY,bZ);

                }
            }
            mysql_free_result();
            return 1;
        }
        else{
            new string[50];
            format(string, sizeof(string), "Casa nao encontrada, retornando ao ponto inicial...");
            GameTextForPlayer(playerid, string, 3000, 4);
            SetPlayerPos(playerid,73.6155,-219.4525,1.5825);
        }
    }
    else if(PVar[playerid][pSpawn]==2){
        if(PVar[playerid][pFaction]!=0){
            new
            Str[100],
            query[128],
            Float:fX,
            Float:fY,
            Float:fZ,
            interior,
            hqid;
           
            format(query, sizeof(query), "SELECT `fX`,`fY`,`fZ`,`interior`,`hqid` FROM `factions` WHERE `factionid`='%d'",GetPlayerFactionid(playerid));
            mysql_query(query);
            mysql_store_result();
            if(mysql_num_rows() > 0)
            {
                while(mysql_fetch_row(Str))
                {
                    sscanf(Str, "p<|>fffdd",fX,fY,fZ,interior,hqid);
                    new string[50];
                    format(string, sizeof(string), "Retornando a sua organizacao...");
                    GameTextForPlayer(playerid, string, 3000, 4);
                    SetPlayerInterior(playerid, interior);
                    SetPlayerPos(playerid,fX,fY,fZ);
                    PVar[playerid][pInside]=hqid;
                }
            }
            mysql_free_result();
            return 1;
        }
        else{
            new string[50];
            format(string, sizeof(string), "Organizacao nao encontrada, retornando ao ponto inicial...");
            GameTextForPlayer(playerid, string, 3000, 4);
            SetPlayerPos(playerid,73.6155,-219.4525,1.5825);
        }
    }
Reply
#2

https://sampwiki.blast.hk/wiki/Fast_Commands#sscanf

Quote:

sscanf(Str, "p<|>fff",bX,bY,bZ);

Remove <>
(Don't forget the second one )
Reply
#3

Didn't work, the problem is that MySQL isn't even receiving the query
Reply
#4

I assume that the plugin has successfully loaded.
Insert a "SendClientMessage()" or the like to make sure that mysql_query() gets even called.
Reply
#5

mySQL is working since the player informations are loading. The query is not even being called, just tested with printf's.

I've also added Playerhashouse(playerid)==1 but nothing..
Reply
#6

Check the if-statements:
if(true)
{

}

(Not all at once, of course)
Like this you can localize the source of the trouble
Reply
#7

Damn, even if I put SetPlayerPos(..); and return 1; only in the OnPlayerSpawn it stills does not works...

The problem is with my OnPlayerSpawn function itself!

How can I fix it?! I'm tottaly lost now.
Reply
#8

Kind of fixed by adding one class at OnGameModeInit.

I think it wasn't looking for the OnPlayerSpawn since there was no classes.

But i tested it a lot of times before and it worked fine, something i added made this bug start.
Reply
#9

If there are no classes defined you will always spawn at "point zero" (x=0, y=0, z=0) in the center of the map
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)