SetSpawnInfo does not change player team(?)
#1

I discovered, when I use SetSpawnInfo on me and I set in this Team: 0, and my friend has same team as me set by SetSpawnInfo too then if we get "GetPlayerTeam" our teams are 0, right? But callback OnPlayerGiveDamage will damage will work on us and we will damage ourself. If we USE SetPlayerTeam to me and my friend team 0 too, then it will not take any damage. So SetSpawnInfo does not work correctly - SetPlayerTeam works correctly.
Reply
#2

I've also noticed this problem yesterday, wondering why
Reply
#3

It's so weird! GetPlayerTeam function returns the player's team but player's team does not work correctly!
Reply
#4

If I recall correctly, SetPlayerTeam even had to be used in SA-MP 0.2. Using the team parameter in SetSpawnInfo then only allowed the usage of /tpm while using SetPlayerTeam wouldn't work for it and vise versa.
Reply
#5

This can be fixed with 1 hook, SetSpawnInfo either by y_hooks or ALS then use SetPlayerTeam and put the team param in it, fixed. This in an include:
PHP Code:
forward SetSpawnInfoHooked(playeridteamskinFloat:xFloat:yFloat:zFloat:rotationweapon1weapon1_ammoweapon2weapon2_ammoweapon3weapon3_ammo);
public 
SetSpawnInfoHooked(playeridteamskinFloat:xFloat:yFloat:zFloat:rotationweapon1weapon1_ammoweapon2weapon2_ammoweapon3weapon3_ammo)
{
    
SetSpawnInfo(playeridteamskinFloat:xFloat:yFloat:zFloat:rotationweapon1weapon1_ammoweapon2weapon2_ammoweapon3weapon3_ammo);
    
SetPlayerTeam(playeridteam);
    return 
1;
}
#if defined _ALS_SetSpawnInfo
  #undef SetSpawnInfo
#else
    #define _ALS_SetSpawnInfo
#endif
#define SetSpawnInfo SetSpawnInfoHooked 
Reply
#6

I reported a similar, if not the same issue here:

https://sampforum.blast.hk/showthread.php?tid=624667

I just use SetPlayerTeam in OnPlayerSpawn to fix it.
Reply
#7

Use SetPlayerTeam( playerid, 255 ); when the player connects and see if it makes a difference.
Reply
#8

Quote:
Originally Posted by RogueDrifter
View Post
This can be fixed with 1 hook, SetSpawnInfo either by y_hooks or ALS then use SetPlayerTeam and put the team param in it, fixed. This in an include:
PHP Code:
forward SetSpawnInfoHooked(playeridteamskinFloat:xFloat:yFloat:zFloat:rotationweapon1weapon1_ammoweapon2weapon2_ammoweapon3weapon3_ammo);
public 
SetSpawnInfoHooked(playeridteamskinFloat:xFloat:yFloat:zFloat:rotationweapon1weapon1_ammoweapon2weapon2_ammoweapon3weapon3_ammo)
{
    
SetSpawnInfo(playeridteamskinFloat:xFloat:yFloat:zFloat:rotationweapon1weapon1_ammoweapon2weapon2_ammoweapon3weapon3_ammo);
    
SetPlayerTeam(playeridteam);
    return 
1;
}
#if defined _ALS_SetSpawnInfo
  #undef SetSpawnInfo
#else
    #define _ALS_SetSpawnInfo
#endif
#define SetSpawnInfo SetSpawnInfoHooked 
This wouldn't be fully correct either. SetSpawnInfo shouldn't set the team when called, it should set the team on the next respawn. Furthermore you can make a much easier fix by doing this in OnPlayerSpawn:

Code:
public OnPlayerSpawn(playerid)
{
SetPlayerTeam(playerid, GetPlayerTeam(playerid));
}
Since GetPlayerTeam returns the correct value, you can just update it, like BeckzyBoi mentioned.
Reply
#9

Quote:
Originally Posted by NaS
View Post
This wouldn't be fully correct either. SetSpawnInfo shouldn't set the team when called, it should set the team on the next respawn. Furthermore you can make a much easier fix by doing this in OnPlayerSpawn:

Code:
public OnPlayerSpawn(playerid)
{
SetPlayerTeam(playerid, GetPlayerTeam(playerid));
}
Since GetPlayerTeam returns the correct value, you can just update it, like BeckzyBoi mentioned.
Oh i had no idea that getplayerteam returned the true value, you're totally right that would indeed be a lot easier and better.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)