SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 18/02/2011, 09:24 PM   #1
kariok
Little Clucker
 
Join Date: Aug 2007
Posts: 48
Reputation: 0
Default Help on OnPlayerSpawn, setting position

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 Code:
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);
        }
    }
kariok is offline  
Old 18/02/2011, 09:39 PM   #2
!Phoenix!
Big Clucker
 
Join Date: Feb 2011
Location: 127.0.0.1 - Germany
Posts: 81
Reputation: 0
Default AW: Help on OnPlayerSpawn, setting position

http://wiki.sa-mp.com/wiki/Fast_Commands#sscanf

Quote:
sscanf(Str, "p<|>fff",bX,bY,bZ);
Remove <>
(Don't forget the second one )
!Phoenix! is offline  
Old 18/02/2011, 09:45 PM   #3
kariok
Little Clucker
 
Join Date: Aug 2007
Posts: 48
Reputation: 0
Default Re: Help on OnPlayerSpawn, setting position

Didn't work, the problem is that MySQL isn't even receiving the query
kariok is offline  
Old 18/02/2011, 09:52 PM   #4
!Phoenix!
Big Clucker
 
Join Date: Feb 2011
Location: 127.0.0.1 - Germany
Posts: 81
Reputation: 0
Default AW: Help on OnPlayerSpawn, setting position

I assume that the plugin has successfully loaded.
Insert a "SendClientMessage()" or the like to make sure that mysql_query() gets even called.
!Phoenix! is offline  
Old 18/02/2011, 09:59 PM   #5
kariok
Little Clucker
 
Join Date: Aug 2007
Posts: 48
Reputation: 0
Default Re: Help on OnPlayerSpawn, setting position

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..
kariok is offline  
Old 18/02/2011, 10:09 PM   #6
!Phoenix!
Big Clucker
 
Join Date: Feb 2011
Location: 127.0.0.1 - Germany
Posts: 81
Reputation: 0
Default AW: Help on OnPlayerSpawn, setting position

Check the if-statements:
if(true)
{

}

(Not all at once, of course)
Like this you can localize the source of the trouble
!Phoenix! is offline  
Old 18/02/2011, 11:32 PM   #7
kariok
Little Clucker
 
Join Date: Aug 2007
Posts: 48
Reputation: 0
Default Re: Help on OnPlayerSpawn, setting position

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.
kariok is offline  
Old 18/02/2011, 11:55 PM   #8
kariok
Little Clucker
 
Join Date: Aug 2007
Posts: 48
Reputation: 0
Default Re: Help on OnPlayerSpawn, setting position

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.
kariok is offline  
Old 19/02/2011, 09:17 AM   #9
!Phoenix!
Big Clucker
 
Join Date: Feb 2011
Location: 127.0.0.1 - Germany
Posts: 81
Reputation: 0
Default AW: Help on OnPlayerSpawn, setting position

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
!Phoenix! is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
onplayerspawn iStarzz Help Archive 4 13/06/2010 10:00 AM
help with onplayerspawn Lajko1 Help Archive 8 14/10/2009 06:22 PM
OnPlayerSpawn GTA_Rules Help Archive 5 18/03/2009 09:47 PM


All times are GMT. The time now is 05:37 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.