SA-MP Forums Archive
OnPlayerSpawn - 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)
+--- Thread: OnPlayerSpawn (/showthread.php?tid=494725)



OnPlayerSpawn - EmpireSk - 14.02.2014

Hi,
I have a problem with OnPlayerSpawn and when I want to spawn only me but we'll flashs from one place to another here is a video and code:

Video:
http://www.youtube.com/watch?v=QU6Vr...ature=*********


Code:
Код:
public OnPlayerSpawn(playerid){
TextDrawShowForPlayer(playerid,Hodiny);
TextDrawShowForPlayer(playerid,www);
TextDrawHideForPlayer(playerid, Logo);
TextDrawHideForPlayer(playerid, Logo2);
SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
Logged[playerid] = 1;
if(PlayerInfo[playerid][pPos_x] == 0 && PlayerInfo[playerid][pPos_y] == 0){
SetPlayerColor(playerid, COLOR_WRITE);
SetPlayerPos(playerid, 1689.0211,1450.3179,10.7673);
SendClientMessage(playerid, COLOR_RED, "[TiP] Hru by jsi mel zacit tim, ze navstivis hlavni centrum mesta.");
SendClientMessage(playerid, COLOR_WRITE, "Toto centrum se nachazi na hlavni tride, Emerald Isle, pobliz policejni stanice.");
SendClientMessage(playerid, COLOR_WRITE, "Muzes si zde udelat ridicsky a pilotni prukaz, nebo zazadat o vydani cestovniho pasu.");
Logged[playerid] = 1;
SpawnPlayer(playerid);
}else{
SetPlayerPos(playerid, PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z]);
Logged[playerid] = 1;
SpawnPlayer(playerid);
}
return 1;
}



Re: OnPlayerSpawn - EmpireSk - 14.02.2014

Help me?


Re: OnPlayerSpawn - Aerotactics - 14.02.2014

Код:
public OnPlayerSpawn(playerid)
{
	TextDrawShowForPlayer(playerid,Hodiny);
	TextDrawShowForPlayer(playerid,www);
	TextDrawHideForPlayer(playerid, Logo);
	TextDrawHideForPlayer(playerid, Logo2);
	SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
	Logged[playerid] = 1;
	if(PlayerInfo[playerid][pPos_x] == 0 && PlayerInfo[playerid][pPos_y] == 0)
	{
		SetPlayerColor(playerid, COLOR_WRITE);
		SetPlayerPos(playerid, 1689.0211,1450.3179,10.7673);
		SendClientMessage(playerid, COLOR_RED, "[TiP] Hru by jsi mel zacit tim, ze navstivis hlavni centrum mesta.");
		SendClientMessage(playerid, COLOR_WRITE, "Toto centrum se nachazi na hlavni tride, Emerald Isle, pobliz policejni stanice.");
		SendClientMessage(playerid, COLOR_WRITE, "Muzes si zde udelat ridicsky a pilotni prukaz, nebo zazadat o vydani cestovniho pasu.");
		Logged[playerid] = 1;
		SpawnPlayer(playerid);
		return 1;
	}
	else
	{
		SetPlayerPos(playerid, PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z]);
		Logged[playerid] = 1;
		SpawnPlayer(playerid);
		return 1;
	}
}
I think your script was looping because it ran through an if/else loop, and not returning a value properly. Sorry if the script wasnt working, just fixed it.


Re: OnPlayerSpawn - EmpireSk - 14.02.2014

it is repaired or is not a


Re: OnPlayerSpawn - CuervO - 14.02.2014

Quote:
Originally Posted by Aerotactics
Посмотреть сообщение
Код:
public OnPlayerSpawn(playerid)
{
	TextDrawShowForPlayer(playerid,Hodiny);
	TextDrawShowForPlayer(playerid,www);
	TextDrawHideForPlayer(playerid, Logo);
	TextDrawHideForPlayer(playerid, Logo2);
	SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
	Logged[playerid] = 1;
	if(PlayerInfo[playerid][pPos_x] == 0 && PlayerInfo[playerid][pPos_y] == 0)
	{
		SetPlayerColor(playerid, COLOR_WRITE);
		SetPlayerPos(playerid, 1689.0211,1450.3179,10.7673);
		SendClientMessage(playerid, COLOR_RED, "[TiP] Hru by jsi mel zacit tim, ze navstivis hlavni centrum mesta.");
		SendClientMessage(playerid, COLOR_WRITE, "Toto centrum se nachazi na hlavni tride, Emerald Isle, pobliz policejni stanice.");
		SendClientMessage(playerid, COLOR_WRITE, "Muzes si zde udelat ridicsky a pilotni prukaz, nebo zazadat o vydani cestovniho pasu.");
		Logged[playerid] = 1;
		SpawnPlayer(playerid);
		return 1;
	}
	else
	{
		SetPlayerPos(playerid, PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z]);
		Logged[playerid] = 1;
		SpawnPlayer(playerid);
		return 1;
	}
}
I think your script was looping because it ran through an if/else loop, and not returning a value properly. Sorry if the script wasnt working, just fixed it.
If's and elses are not loops, they are conditionals, at least in PAWN. A loop is something that repeats itself a fixed number of times (can be infinite too).


Re: OnPlayerSpawn - EmpireSk - 14.02.2014

CuervO? How would I corrected you think?


Re: OnPlayerSpawn - CuervO - 14.02.2014

It is always returning SpawnPlayer, which causes an infinite number of OnPlayerSpawn processings. Remove SpawnPlayer at OnPlayerSpawn, it's senseless. Aerotactics was partially right though, it was an unintended loop.


Re: OnPlayerSpawn - lsreskjn - 14.02.2014

Quote:
Originally Posted by CuervO
Посмотреть сообщение
It is always returning SpawnPlayer, which causes an infinite number of OnPlayerSpawn processings. Remove SpawnPlayer at OnPlayerSpawn, it's senseless. Aerotactics was partially right though, it was an unintended loop.
Radi ti dobre, daj preč SpawnPlayer


Re: OnPlayerSpawn - EmpireSk - 14.02.2014

Thanks