SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 08/12/2013, 08:57 PM   #1
Uuri
Little Clucker
 
Join Date: Dec 2013
Posts: 20
Reputation: 0
Default Player Spawn Bug

Hey. When I run my game mode the player is supposed to spawn at the coordinates given in OnPlayerSpawn. Its works perfectly but after I press the "Spawn" button the screen flashes showing my player at the default samp coordinates(the little place with the elevators) and then spawns to the correct position. How can I fix that flash?

Code:
public OnPlayerSpawn(playerid)
{
	//Hide the textdraw when the player spawns
	TextDrawHideForPlayer(playerid, gWelcome);

	//Print a client message to all players when a player spawns
	new name[MAX_PLAYER_NAME];
	new string [128];
	GetPlayerName(playerid, name, sizeof(name));
	format(string, sizeof(string), "%s has spawned!", name);
	SendClientMessageToAll(LIGHT_GREEN, string);

	//Set the players coordinates to spawn; put camera behind player
	SetPlayerPos(playerid, 1280.5247,-813.6929,83.6532);
	SetPlayerCameraPos(playerid, 1280.5247,-813.6929,83.6532);
	SetPlayerFacingAngle(playerid, 180.0);
	SetCameraBehindPlayer(playerid);
	return 1;
}

public OnGameModeInit()
{
	SetGameModeText("Closed Beta");
	AddPlayerClass(210, 1958.3783, 1343.1572, 15.3746, 269.1425, 24, 123123, 25, 123123, 34, 123123);
	AddPlayerClass(230, 1958.3783, 1343.1572, 15.3746, 269.1425, 24, 123123, 25, 123123, 34, 123123);
	AddPlayerClass(38, 1958.3783, 1343.1572, 15.3746, 269.1425, 24, 123123, 25, 123123, 34, 123123);
	AddPlayerClass(53, 1958.3783, 1343.1572, 15.3746, 269.1425, 24, 123123, 25, 123123, 34, 123123);
 	AddPlayerClass(134, 1958.3783, 1343.1572, 15.3746, 269.1425, 24, 123123, 25, 123123, 34, 123123);
 	AddPlayerClass(170, 1958.3783, 1343.1572, 15.3746, 269.1425, 24, 123123, 25, 123123, 34, 123123);
 	AddPlayerClass(177, 1958.3783, 1343.1572, 15.3746, 269.1425, 24, 123123, 25, 123123, 34, 123123);
 	
 	//Create some nrg's
 	AddStaticVehicle(522,1293.4578,-831.7721,82.7060,2.2115,8,164);
 	AddStaticVehicle(522,1291.4998,-832.0693,82.7150,0.9063,1,89);
 	AddStaticVehicle(522,1289.1138,-832.2216,82.7144,1.8299,20,0);
	AddStaticVehicle(522,1286.9045,-832.1899,82.7124,357.0424,150,49);
	AddStaticVehicle(522,1283.9424,-832.0230,82.7132,1.8036,200,78);
	
	AddStaticVehicle(411,1242.7148,-805.3672,83.8677,178.3237,1,0); // infernous
	AddStaticVehicle(451,1248.9519,-805.4118,83.8476,178.6428,0,1); // turismo
	AddStaticVehicle(541,1255.2100,-804.8454,83.7656,184.1492,1,0); // bullet

	//Create the textdraw for welcoming the player
	gWelcome = TextDrawCreate(320.0, 240.0, "Welcome to Uuri's Mapping Server!");
	TextDrawSetShadow(gWelcome, 3);
	TextDrawSetOutline(gWelcome, 2);
	TextDrawFont(gWelcome, 3);
	TextDrawBoxColor(gWelcome, 0x003333FF);
	TextDrawAlignment(gWelcome, 2);

	//Use the running animations I like
	UsePlayerPedAnims();

	return 1;
}

public OnPlayerConnect(playerid)
{
	//Show the player the welcome textdraw
	TextDrawShowForPlayer(playerid, gWelcome);
	
	//Send a client message to all players on the current player connecting.
	new name[MAX_PLAYER_NAME];
	new string[128];
	GetPlayerName(playerid, name, sizeof(name));
	format(string, sizeof(string), "%s has connected to the server!", name);
    SendClientMessageToAll(LIGHT_GREEN, string);
    
	return 1;
	
}

public OnPlayerRequestClass(playerid, classid)
{
	SetPlayerPos(playerid, 2000.5919,1527.3319,14.6172);
	SetPlayerCameraPos(playerid, 2000.6874,1528.9332,14.6223);
	SetPlayerCameraLookAt(playerid, 2000.5919,1527.3319,14.6172);
	SetPlayerFacingAngle(playerid, 358.2982);
	
	return 1;
}
Uuri is offline   Reply With Quote
Old 08/12/2013, 09:09 PM   #2
Chasm
Little Clucker
 
Join Date: Mar 2013
Location: Everywhere.
Posts: 46
Reputation: 0
Default Re: Player Spawn Bug

It could be because you have SetPlayerCameraPos under OnPlayerSpawn.
Remove that and try again.
Chasm is offline   Reply With Quote
Old 08/12/2013, 09:14 PM   #3
Uuri
Little Clucker
 
Join Date: Dec 2013
Posts: 20
Reputation: 0
Default Re: Player Spawn Bug

It worked but now I can't see my skin on the skin selection screen.
Uuri is offline   Reply With Quote
Old 08/12/2013, 09:19 PM   #4
Chasm
Little Clucker
 
Join Date: Mar 2013
Location: Everywhere.
Posts: 46
Reputation: 0
Default Re: Player Spawn Bug

Hmm, try to remove SetCameraBehindPlayer under OnPlayerSpawn as well. See if it works.
Also, maybe get new coordinates for OnPlayerRequestClass. This might fix it as well.
Chasm is offline   Reply With Quote
Old 08/12/2013, 09:22 PM   #5
Uuri
Little Clucker
 
Join Date: Dec 2013
Posts: 20
Reputation: 0
Default Re: Player Spawn Bug

It didn't work...

Last edited by Uuri; 09/12/2013 at 12:39 AM.
Uuri is offline   Reply With Quote
Old 09/12/2013, 12:39 AM   #6
Uuri
Little Clucker
 
Join Date: Dec 2013
Posts: 20
Reputation: 0
Default Re: Player Spawn Bug

Bump, please help me.
Uuri is offline   Reply With Quote
Old 09/12/2013, 12:23 PM   #7
CrossOv3r
Gangsta
 
CrossOv3r's Avatar
 
Join Date: Jun 2012
Location: Antofagasta - Chile
Posts: 689
Reputation: 55
Default Re: Player Spawn Bug

Try using this callback:
wiki.sa-mp.com/wiki/OnPlayerRequestSpawn

And dont use cameras functions, just set the player position.
CrossOv3r is offline   Reply With Quote
Old 09/12/2013, 09:13 PM   #8
Uuri
Little Clucker
 
Join Date: Dec 2013
Posts: 20
Reputation: 0
Default Re: Player Spawn Bug

Okay I used it but now the Spawn dialog is still showing and I can't walk or do anything I copied and pasted this inside it.

Code:
        SetPlayerPos(playerid, 1280.5247,-813.6929,83.6532);	
        SetCameraBehindPlayer(playerid);
	SetPlayerFacingAngle(playerid, 180.0);
Uuri is offline   Reply With Quote
Old 09/12/2013, 09:47 PM   #9
CrossOv3r
Gangsta
 
CrossOv3r's Avatar
 
Join Date: Jun 2012
Location: Antofagasta - Chile
Posts: 689
Reputation: 55
Default Respuesta: Player Spawn Bug

Please, try to use this:

pawn Code:
public OnPlayerSpawn(playerid)
{
    //Hide the textdraw when the player spawns
    TextDrawHideForPlayer(playerid, gWelcome);

    //Print a client message to all players when a player spawns
    new name[MAX_PLAYER_NAME];
    new string [128];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "%s has spawned!", name);
    SendClientMessageToAll(LIGHT_GREEN, string);

    //Set the players coordinates to spawn; put camera behind player
    SetPlayerPos(playerid, 1280.5247,-813.6929,83.6532);
    SetPlayerFacingAngle(playerid, 180.0);
    return 1;
}

Don't use ANY camera function. And I'm surprised about your comment #3.

P.S: Remove OnPlayerRequestSpawn then.

P.S2: Wut dialog? I don't see any dialog function in your code.
CrossOv3r is offline   Reply With Quote
Old 09/12/2013, 10:02 PM   #10
Uuri
Little Clucker
 
Join Date: Dec 2013
Posts: 20
Reputation: 0
Default Re: Respuesta: Player Spawn Bug

Quote:
Originally Posted by CrossOv3r View Post
Please, try to use this:

pawn Code:
public OnPlayerSpawn(playerid)
{
    //Hide the textdraw when the player spawns
    TextDrawHideForPlayer(playerid, gWelcome);

    //Print a client message to all players when a player spawns
    new name[MAX_PLAYER_NAME];
    new string [128];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "%s has spawned!", name);
    SendClientMessageToAll(LIGHT_GREEN, string);

    //Set the players coordinates to spawn; put camera behind player
    SetPlayerPos(playerid, 1280.5247,-813.6929,83.6532);
    SetPlayerFacingAngle(playerid, 180.0);
    return 1;
}

Don't use ANY camera function. And I'm surprised about your comment #3.

P.S: Remove OnPlayerRequestSpawn then.

P.S2: Wut dialog? I don't see any dialog function in your code.
If you use OnPlayerRequestSpawn then you'll have a dialog.
Uuri is offline   Reply With Quote
Reply

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
Make the player spawn after logging in, without hitting "Spawn" Dubya Scripting Help 4 17/01/2018 01:48 PM
spawn player without having to press spawn lean1337 Scripting Help 4 15/02/2013 09:35 PM
[Help] Object/item ectra spawn on player spawn? No-Half-Measures Help Archive 3 21/01/2010 10:38 AM
How to Return a Player's Spawn, Use it for another player's checkpoint? Ace_Menace Help Archive 0 02/12/2009 02:18 AM
How to Return a Player's Spawn, Use it for another player's checkpoint? Ace_Menace Help Archive 1 02/12/2009 02:00 AM


All times are GMT. The time now is 10:40 PM.


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