SetSpawnInfo is behaving weird
#1

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.
Reply
#2

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

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.
Reply
#4

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.
Reply
#5

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).

Reply
#6

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.);
        }
Reply
#7

Код:
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?
Reply
#8

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!
Reply
#9

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

It's meant to be OnPlayerSpawn :S
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)