20.12.2016, 17:24
If SetSpawnInfo is used in OnPlayerDeath, the team parameter has no effect when the player spawns. SetPlayerTeam must be used in OnPlayerSpawn to workaround this.
#include <a_samp>
public OnPlayerSpawn(playerid) {
//If the bug persists, it shouldn't show 2.
new
temp_String[64];
format(temp_String, sizeof(temp_String), "Your team : %d", GetPlayerTeam(playerid));
SendClientMessage(playerid, -1, temp_String);
return 1;
}
public OnPlayerConnect(playerid) {
SetPlayerTeam(playerid, 1);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason) {
SetSpawnInfo(playerid, 2, 0, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[]) {
if(!strcmp(cmdtext, "/kill", true)) {
SetPlayerHealth(playerid, 0.0);
return 1;
}
if(!strcmp(cmdtext, "/changeteam", true)) {
SetPlayerTeam(playerid, 3);
return 1;
}
if(!strcmp(cmdtext, "/defaultteam", true)) {
OnPlayerConnect(playerid);
return 1;
}
if(!strcmp(cmdtext, "/spawnme", true)) {
SpawnPlayer(playerid);
return 1;
}
return 0;
}