SA-MP Forums Archive
OnPlayerSpawn is not called - 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 is not called (/showthread.php?tid=629818)



OnPlayerSpawn is not called - Saddin - 04.03.2017

Here is my OnPlayerSpawn:

Код:
public OnPlayerSpawn(playerid)
{
    new PlayerName[MAX_PLAYER_NAME],
    string[40];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    format(string, sizeof(string), "%s has spawned successfully.", PlayerName);
    SendClientMessageToAll(0xFFFFFFFF, string);  

	
	SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 1);
	SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 1);
	SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 1);
	SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 1);
	
	
	SetPlayerColor(playerid, -1);
	SetPlayerHealth(playerid, 100.0);
	SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
	SetCameraBehindPlayer(playerid);
	StopAudioStreamForPlayer(playerid);

    return 1;
}
It doesnt work, i spawn successfuly but it wont work... I dont get the message and it wont change my skin/color, any of this.


Re: OnPlayerSpawn is not called - Unrea1 - 04.03.2017

Add more value for string, exactly 50.

Код:
string[50]
24 (Name player) + 26 (Letters) = 50.


Re: OnPlayerSpawn is not called - Saddin - 04.03.2017

Quote:
Originally Posted by Fynn.
Посмотреть сообщение
Add more value for string, exactly 50.

Код:
string[50]
24 (Name player) + 26 (Letters) = 50.
that is not the problem, it wont execute any of the instructions


Re: OnPlayerSpawn is not called - Yuri8 - 04.03.2017

Use the functions at OnPlayerConnect, only the message is ok.


Re: OnPlayerSpawn is not called - Saddin - 04.03.2017

Quote:
Originally Posted by Yuri8
Посмотреть сообщение
Use the functions at OnPlayerConnect, only the message is ok.
i need to set health, skin, weaponskill, stop audio stream every time when player spawn, that will not solve anything..


Re: OnPlayerSpawn is not called - Toroi - 04.03.2017

Swap the order of these things, like this:

Код:
public OnPlayerSpawn(playerid)
{
	SetPlayerColor(playerid, -1);
	SetPlayerHealth(playerid, 100.0);
	SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
	SetCameraBehindPlayer(playerid);
	StopAudioStreamForPlayer(playerid);

	SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 1);
	SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 1);
	SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 1);
	SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 1);

	new PlayerName[MAX_PLAYER_NAME],string[51];
	GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
	format(string, sizeof(string), "%s has spawned successfully.", PlayerName);
	SendClientMessageToAll(0xFFFFFFFF, string);  

	return 1;
}



Re: OnPlayerSpawn is not called - Saddin - 04.03.2017

not working...


Re: OnPlayerSpawn is not called - SyS - 04.03.2017

Do you have any runtime error ? Check server log and also run server with crash detect


Re: OnPlayerSpawn is not called - Saddin - 04.03.2017

Quote:
Originally Posted by Sreyas
Посмотреть сообщение
Do you have any runtime error ? Check server log and also run server with crash detect
i checked server.cfg for crashdetector and i noticed i didn't put .so extension on any plugin i added, thanks for that, helped me, really stupid thing..


now i checked the log and i got 1 runtime error:

[16:30:52] [debug] Run time error 20: "Invalid index parameter (bad entry point)"


Re: OnPlayerSpawn is not called - NaS - 04.03.2017

Quote:
Originally Posted by Saddin
Посмотреть сообщение
i checked server.cfg for crashdetector and i noticed i didn't put .so extension on any plugin i added, thanks for that, helped me, really stupid thing..


now i checked the log and i got 1 runtime error:

[16:30:52] [debug] Run time error 20: "Invalid index parameter (bad entry point)"
No AddPlayerClass in OnGameModeInit?


Re: OnPlayerSpawn is not called - Saddin - 04.03.2017

Quote:
Originally Posted by NaS
Посмотреть сообщение
No AddPlayerClass in OnGameModeInit?
no because i dont want to use those player classes, im making rp kind of script


Re: OnPlayerSpawn is not called - SyS - 04.03.2017

Add main(){} to your gm


Re: OnPlayerSpawn is not called - Saddin - 04.03.2017

Quote:
Originally Posted by Sreyas
Посмотреть сообщение
Add main(){} to your gm
i have that already


Re: OnPlayerSpawn is not called - NaS - 04.03.2017

Quote:
Originally Posted by Saddin
Посмотреть сообщение
no because i dont want to use those player classes, im making rp kind of script
You need to add classes (1 at least to be exact), there is no way around that!

What you mean is probably UsePlayerPedAnims (which affects the movement style of all skins)?


Re: OnPlayerSpawn is not called - Toroi - 04.03.2017

Quote:
Originally Posted by NaS
Посмотреть сообщение
You need to add classes (1 at least to be exact), there is no way around that!

What you mean is probably UsePlayerPedAnims (which affects the movement style of all skins)?
You are not forced to add any class if you want, it's not needed at all for everything else to work.


Re: OnPlayerSpawn is not called - Saddin - 04.03.2017

Quote:
Originally Posted by NaS
Посмотреть сообщение
You need to add classes (1 at least to be exact), there is no way around that!

What you mean is probably UsePlayerPedAnims (which affects the movement style of all skins)?
I dont mean that, i know gamemodes that dont have AddPlayerClass and still works, but i dont know whats wrong with this...