SA-MP Forums Archive
Help on OnPlayerSpawn, setting position - 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 on OnPlayerSpawn, setting position (/showthread.php?tid=228055)



Help on OnPlayerSpawn, setting position - kariok - 18.02.2011

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



AW: Help on OnPlayerSpawn, setting position - !Phoenix! - 18.02.2011

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

Quote:

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

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


Re: Help on OnPlayerSpawn, setting position - kariok - 18.02.2011

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


AW: Help on OnPlayerSpawn, setting position - !Phoenix! - 18.02.2011

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


Re: Help on OnPlayerSpawn, setting position - kariok - 18.02.2011

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..


AW: Help on OnPlayerSpawn, setting position - !Phoenix! - 18.02.2011

Check the if-statements:
if(true)
{

}

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


Re: Help on OnPlayerSpawn, setting position - kariok - 18.02.2011

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.


Re: Help on OnPlayerSpawn, setting position - kariok - 18.02.2011

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.


AW: Help on OnPlayerSpawn, setting position - !Phoenix! - 19.02.2011

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