SA-MP Forums Archive
SetSpawnInfo is behaving weird - 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: SetSpawnInfo is behaving weird (/showthread.php?tid=305788)



SetSpawnInfo is behaving weird - Giovanni - 23.12.2011

So I am currently testing the map system of my script. Every float variable (for spawns etc.) is getting loaded out of text files, and that is working perfectly. But I got a problem with the function: SetSpawnInfo.

(Note: The loading of the variables works fine)

This is how the actual code looks like:




@: OnPlayerSpawn
pawn Код:
switch(gTeam[playerid])
    {
        case TEAM_1:
        {
                SetSpawnInfo(playerid, TEAM_1 , -1 , s_spawnx, s_spawny , s_spawnz, s_spawna, -1, -1, -1, -1, -1, -1);
        }

...
When I use the code like this (@ OnPlayerSpawn) I don't get spawned at the wished location (I get spawned at point 0). Everything else works fine (I get weapons + my skin is the right one).

But:

If I use the same code under OnPlayerRequestClass I do get spawned at the wished location. This option gives me some other problems though:

- Warning messages appear that make the client sooner or later crash
- It doesn't pass the skin IDs I've chosen with AddPlayerClass
- I spawn without any weapons

I've read on the Wiki that you can use the function at OnPlayerSpawn but also at OnPlayerRequestClass, so I honestly don't really understand this.



Thanks in advance.


Re: SetSpawnInfo is behaving weird - iTorran - 23.12.2011

pawn Код:
SetSpawnInfo(...
SpawnPlayer(playerid);



AW: SetSpawnInfo is behaving weird - Giovanni - 23.12.2011

I don't really know if this is useful since it is under OnPlayerSpawn anyways. But I added it, and tested it. Now I do get spawned at the right place but I 1.) Don't have the right skin and 2.) Don't have any weapons.


Re: SetSpawnInfo is behaving weird - Ballu Miaa - 24.12.2011

Check the AddPlayerClass function in OnGameModeInIt() you might have entered wrong id there. On the same AddPlayerClass function you can add weapons also. Use SAMP wiki for syntax help.


AW: Re: SetSpawnInfo is behaving weird - Giovanni - 24.12.2011

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
Check the AddPlayerClass function in OnGameModeInIt() you might have entered wrong id there. On the same AddPlayerClass function you can add weapons also. Use SAMP wiki for syntax help.
That didn't help me at all, and I do know how to use AddPlayerClass...

Quote:

When I use the code like this (@ OnPlayerSpawn) I don't get spawned at the wished location (I get spawned at point 0). Everything else works fine (I get weapons + my skin is the right one).




Re: SetSpawnInfo is behaving weird - Thresholdold - 24.12.2011

Can you just use SetPlayerPos ?? (Put under OnPlayerSpawn so you spawn with weapons and skin properly)

pawn Код:
switch(gTeam[playerid])
    {
        case TEAM_1:
        {
                SetSpawnInfo(playerid, TEAM_1 , -1 , s_spawnx, s_spawny , s_spawnz, s_spawna, -1, -1, -1, -1, -1, -1);
                SetPlayerPos(etc. etc.);
        }



Re: SetSpawnInfo is behaving weird - prisonliferp - 24.12.2011

Код:
public OnPlayerUpdate()

switch(gTeam[playerid])
    {
        case TEAM_1:
        {
                SetSpawnInfo(playerid, TEAM_1 , -1 , s_spawnx, s_spawny , s_spawnz, s_spawna, -1, -1, -1, -1, -1, -1);
		SpawnPlayer(playerid);
		SetPlayerSkin(playerid,SKINIDHERE);
        }

	return 1;
    }
Un-tested, but try it out? + Rep if it works :3


-Threshold, The spawn position has allready been made under the "SetSpawnInfo" -He just wants the player to spawn and get a skin, which it basicly should in my code?


Re: SetSpawnInfo is behaving weird - Thresholdold - 24.12.2011

Is that a joke or am I just seeing things... you put it under OnGameModeInit? That will definitely screw the server...

EDIT: My code is just an option, obviously the code he has now does not function properly, so this is just an alternative choice... unlike your code which will most likely ruin it even more.

And now you have OnPlayerUpdate? Even worse!


Re: SetSpawnInfo is behaving weird - prisonliferp - 24.12.2011

Yea, I just noticed the OnGameModeInit, it was supposed to be OnPlayerUpdate, but okay... I'm not a scripter >.<


Re: SetSpawnInfo is behaving weird - Thresholdold - 24.12.2011

It's meant to be OnPlayerSpawn :S