Spawning [+REP]
#1

After a player logs in, they should spawn at a certain location - however when I hit login, my character is sent into the air.

Codes:

Under DialogResponse(snipet):
Код:
	                SetCameraBehindPlayer( playerid );
	                LoadAccountVariables( playerid );
	                gPlayerLogged[playerid] = 1;
LoadAccountVar:
Код:
stock LoadAccountVariables( playerid )
{
    if( IsPlayerConnected( playerid ) )
	{
        new DataString[ 1536 ], Query[ 1536 ];

        format( Query, sizeof( Query ), "SELECT * FROM `Accounts` WHERE `UserID` = '%d'", PlayerInfo[playerid][pDatabaseID] );
		if(mysql_query( Query ))
	    {
			mysql_store_result();
		} else {
		    mysql_free_result();
            SendClientMessage( playerid, COLOR_WHITE, "MYSQL ERROR LAV, feel free to report this bug by SS'ing it and send it to a dev." );
			printf("Could not call loadaccountvariables query %d %d",playerid,PlayerInfo[playerid][pDatabaseID]);
			Kick(playerid);
		}
        printf(" SQL: %s",Query);

        mysql_fetch_field( "Rank", DataString );
        PlayerInfo[ playerid ][ pRank ] = strval( DataString );

        mysql_fetch_field( "Admin", DataString );
        PlayerInfo[ playerid ][ pAdmin] = strval( DataString );
        SpawnPlayer( playerid );
        SetPlayerSpawn(playerid);
        }
    else
	{
        printf( "[error] LoadAccountVariables() was called, but to a non-connected ID.", playerid );
    }
}
SetPlayerSpawn:
Код:
forward SetPlayerSpawn(playerid);
public SetPlayerSpawn(playerid)
{
	SetPlayerPos(playerid,1742.8767,-1863.5521,13.5749);
	SetPlayerVirtualWorld(playerid, 0);
	SetPlayerInterior(playerid, 0);
	SetPlayerFacingAngle(playerid,0);
	SetPlayerHealth(playerid,100);
	gPlayerLogged[playerid] = 1;
	if(PlayerInfo[playerid][pAdmin] > 0)
	{
		new string2[64];
		format(string2, sizeof(string2), "SERVER: You are logged in as a level %d admin",PlayerInfo[playerid][pAdmin]);
		SendClientMessage(playerid, COLOR_WHITE,string2);
	}
	return 1;
}
OnPlayerRequestClass:
Код:
public OnPlayerRequestClass(playerid, classid)
{
	if(IsPlayerNPC(playerid)) return 1;
	SetPlayerSkin(playerid, 71);
	if(gPlayerLogged[playerid] != 1)
	{
        InitPlayerConnection( playerid );
	} else {
		SpawnPlayer(playerid);
	}
   	return 0;
}
PlayerRequestSpawn:

Код:
public OnPlayerRequestSpawn(playerid)
{
	if(IsPlayerNPC(playerid)) return 1;
	if(gPlayerLogged[playerid] == 1)
	{ return 1; }
	else {
	    if(SpawnAttempts[playerid] >= MAX_SPAWN_ATTEMPTS)
	    {
	        Kick(playerid);
			return 1;
	    }
		SpawnAttempts[playerid] ++;
		return 0;
	}
}
Please help me, as I need this fixed ASAP.
Reply


Messages In This Thread
Spawning [+REP] - by EliteApple - 31.05.2013, 13:29
Re: Spawning [+REP] - by Kovon - 31.05.2013, 17:35

Forum Jump:


Users browsing this thread: 1 Guest(s)