SA-MP Forums Archive
SetSpawnInfo does not change player team(?) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP (https://sampforum.blast.hk/forumdisplay.php?fid=3)
+--- Forum: Bug Reports (https://sampforum.blast.hk/forumdisplay.php?fid=20)
+--- Thread: SetSpawnInfo does not change player team(?) (/showthread.php?tid=649396)



SetSpawnInfo does not change player team(?) - Milak - 08.02.2018

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.


Re: SetSpawnInfo does not change player team(?) - Matz - 10.02.2018

I've also noticed this problem yesterday, wondering why


Re: SetSpawnInfo does not change player team(?) - Milak - 11.02.2018

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


Re: SetSpawnInfo does not change player team(?) - Banana_Ghost - 14.02.2018

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.


Re: SetSpawnInfo does not change player team(?) - RogueDrifter - 14.02.2018

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 



Re: SetSpawnInfo does not change player team(?) - beckzy - 17.02.2018

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.


Re: SetSpawnInfo does not change player team(?) - Kane - 17.02.2018

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


Re: SetSpawnInfo does not change player team(?) - NaS - 17.02.2018

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.


Re: SetSpawnInfo does not change player team(?) - RogueDrifter - 17.02.2018

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.