bugged blueberry & senddeathmessage
#1

iam death with a gun, but why after send death with a gun, send again suicide ? this make my server bugged, and sometimes can spawn at blueberry

this code
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	if(PlayerInfo[playerid][Logged] == 1)
	{
		SendDeathMessage(killerid, playerid, reason);
		PlayerInfo[playerid][pDeaths]++;
		PlayerInfo[killerid][pKills]++;
		new str[254];
		format(str,sizeof(str),"{FFFF00}[DEATH]: {FFFFFF}You have been killed by %s.",GetName(killerid));
		SendClientMessage(playerid,-1,str);
		format(str,sizeof(str), "[DEATH] %s killed %s ", GetName(killerid) , GetName(playerid));
		Log("death", str);
		if(team[playerid] == HUMAN) team[playerid] = ZOMBIE;
	}
	return 1;
}
Reply
#2

You have to check if killerid != INVALID_PLAYER_ID when using the killerid parameter.
Reply
#3

no change at all
bug will be make double anti spawn kill, then if player death again, will be spawned at bb
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	if(PlayerInfo[playerid][Logged] == 1)
	{
		if(killerid != INVALID_PLAYER_ID)
		{
			SendDeathMessage(killerid, playerid, reason);
			PlayerInfo[playerid][pDeaths]++;
			if(team[killerid] == HUMAN) PlayerInfo[killerid][pHumanKills]++,PlayerInfo[killerid][pXP] += 3;
			if(team[killerid] == ZOMBIE) PlayerInfo[killerid][pZombieKills]++,PlayerInfo[killerid][pXP] += 2;
			new str[254];
			format(str,sizeof(str),"{FFFF00}[DEATH]: {FFFFFF}You have been killed by %s.",GetName(killerid));
			SendClientMessage(playerid,-1,str);
			format(str,sizeof(str), "[DEATH] %s killed %s ", GetName(killerid) , GetName(playerid));
			Log("death", str);
			if(team[playerid] == HUMAN) team[playerid] = ZOMBIE;
		}
	}
	return 1;
}
Reply
#4

I didn't say put the whole OnPlayerDeath inside the check.

PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    if(
PlayerInfo[playerid][Logged] == 1)
    {
        new 
str[100];
        
SendDeathMessage(killeridplayeridreason);
        
        if(
killerid != INVALID_PLAYER_ID) {
            
PlayerInfo[killerid][pKills]++;
            
format(str,sizeof(str),"{FFFF00}[DEATH]: {FFFFFF}You have been killed by %s.",GetName(killerid));
            
SendClientMessage(playerid,-1,str);
            
format(str,sizeof(str), "[DEATH] %s killed %s "GetName(killerid) , GetName(playerid));
            
Log("death"str);
        }
        
PlayerInfo[playerid][pDeaths]++;
        if(
team[playerid] == HUMANteam[playerid] = ZOMBIE;
    }
    return 
1;

Reply
#5

do nothing

http://imgur.com/a/P0TSd
Reply
#6

There must be some code that tried to change the player's skin/spawn info or state when the player dies. Check for OnPlayerDeath in other running scripts, give your code of your AddPlayerClass or anything that uses SetSpawnInfo.

I'm pretty sure there is nothing wrong on your OnPlayerDeath code, because it's just basically sending messages and incrementing player variable's except the part where you are trying to change the human to zombies:
Код:
if(team[playerid] == HUMAN) team[playerid] = ZOMBIE;
Comment that line and try again, if you respawned normally but didn't change into a zombie yet, then the problem is another callback like a Timer/OnPlayerUpdate that tracks the team[playerid] variable when it's changed where it gets triggerred to change the player's Spawn Info/Skin/Class.

If you do not know where to find, just look for the line where it sends message "[INFECTION] %s has become a zombie". It should be around there, show us the code if you don't know how to fix it.
Reply
#7

I think so, in the callback "OnPlayerDeath" it seems there is no problem
I've checked the human part that converts into a zombie, but it seems there is no error, I also do not put filterscript, setspawninfo, and addplayerclass

this callback human change to zombie
Код:
Timer:ServerUpdate[1250]() // frrm y less
{
	if(GameOver == false)
	{
		MapInfo[Durasi]--;
		if(MapInfo[Durasi] == MapInfo[Deadtime])
		{
			new str[254];
			new randomid = Iter_Random(Player);
			format(str,sizeof(str),"{FFFF00}[INFECTION]: {FFFFFF}%s has become a zombie.",GetName(randomid));
			SendClientMessageToAll(-1,str);
			GameTextForAll("~r~zombies~w~ come, ~g~save~w~ yourself from a zombie ~r~attack~r~", 4000, 4);
			SetPlayerZombie(randomid);
			printf("%s selected to be a zombie!", GetName(randomid));
		}
	}
	return 1;
}
public OnPlayerSpawn(playerid)
{
	if(MapInfo[Durasi] <= MapInfo[Deadtime])
	{
		SetPlayerZombie(playerid);
	}
	else 
	{
		SetPlayerHuman(playerid);
	}
	return 1;
}
then this SetPlayerZombie
Код:
stock SetPlayerZombie(playerid)
{
	SetPlayerColor(playerid,ZOMBIE_COLOR);
	SetPlayerTeam(playerid,ZOMBIE);
	team[playerid] = ZOMBIE;
	SetPlayerHealth(playerid, 100.0);
	switch(random(4))
	{
        case 0: SetPlayerSkin(playerid,162);
        case 1: SetPlayerSkin(playerid,135);
        case 2: SetPlayerSkin(playerid,137);
        case 3: SetPlayerSkin(playerid,196);
	}
	ResetPlayerWeapons(playerid);
	ClearAnimations(playerid);
	return 1;
}
Reply
#8

There it is your problem, in the timer, you should check if the player is still alive or not before using SetPlayerZombie. Because you should not use SetPlayerSkin when the player just died, otherwise you will get "spawn-glitch", having the "smoking" animation, spawning in the center of san andreas (0.0, 0.0, 0.0) where you fall down out of the map and getting teleported back on the ground near blueberry.
Код:
stock SetPlayerZombie(playerid)
{
	new playerstate = GetPlayerState(playerid);
	if(playerstate >=  PLAYER_STATE_ONFOOT && playerstate <= PLAYER_STATE_ENTER_VEHICLE_PASSENGER)
	{
		SetPlayerColor(playerid,ZOMBIE_COLOR);
		SetPlayerTeam(playerid,ZOMBIE);
		team[playerid] = ZOMBIE;
		SetPlayerHealth(playerid, 100.0);
		switch(random(4))
		{
        	case 0: SetPlayerSkin(playerid,162);
        	case 1: SetPlayerSkin(playerid,135);
       		case 2: SetPlayerSkin(playerid,137);
        	case 3: SetPlayerSkin(playerid,196);
		}
		ResetPlayerWeapons(playerid);
		ClearAnimations(playerid);
		return 1; // player sucessfully becomes a zombie
	}
	return 0; // player was failed to be a zombie
}
Now the problem is, you wont be turned into zombie if the code was called when you just death or in spectate screen. You have to do that if-else statement like above.

So assuming that you want to turn the "human" into a "zombie", with having this OnPlayerDeath:
Код:
if(team[playerid] == HUMAN) team[playerid] = ZOMBIE;
Then you can just add it like this OnPlayerSpawn:
Код:
public OnPlayerSpawn(playerid)
{
	if(MapInfo[Durasi] <= MapInfo[Deadtime])
	{
		SetPlayerZombie(playerid);
	}
	else 
	{
		if(team[playerid] == HUMAN) SetPlayerHuman(playerid);
		else SetPlayerZombie(playerid);
	}
	return 1;
}
Something like that, hope you understand, just test it and it's up to you how you want the logic be, otherwise it will be still buggy at some cases, e.g. it's the time to change random humans to zombies but the player was dead/not spawned, they might be still a human.

Or just use the return code of SetPlayerZombie on here:
Код:
Timer:ServerUpdate[1250]() // frrm y less
{
	if(GameOver == false)
	{
		MapInfo[Durasi]--;
		if(MapInfo[Durasi] == MapInfo[Deadtime])
		{
			new str[254];
			do
			{
				new randomid = Iter_Random(Player);
			}
			while(team[randomid] == ZOMBIE || SetPlayerZombie(randomid) == 0); // This will keep picking another player id when the one picked was failed to be a zombie (player was already a zombie or was not alive).

			format(str,sizeof(str),"{FFFF00}[INFECTION]: {FFFFFF}%s has become a zombie.",GetName(randomid));
			SendClientMessageToAll(-1,str);
			GameTextForAll("~r~zombies~w~ come, ~g~save~w~ yourself from a zombie ~r~attack~r~", 4000, 4);
			printf("%s selected to be a zombie!", GetName(randomid));
		}
	}
	return 1;
}
Note that if you use the code like this, it means the player who just died wont be able to be a zombie when the timer gets called. It will still make them into a zombie if they died normally from a zombie infection since we have the code in OnPlayerDeath & OnPlayerSpawn. But that's up to you how you want the logic.


EDIT: nvm, see the code changes above.
Sorry for my bad english.
Reply
#9

hi, sorry for late reply, I just had time to test it today
seems to remain unchanged man, death message remains the case twice, if it dies, it will respawn in place blueberries

Reply
#10

bump!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)