OnPlayerDeath Problem.
#1

Help.

Problem: When player is spawning then he is connecting on the server,the player give the message "Paramedics saved you for 5 dollars."

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	deatht[playerid] = SetTimerEx("DeathTimer", 1500, 0, "i", playerid);

Код:
public DeathTimer(playerid)
{
	new Float:healtht;
	GetPlayerHealthEx(playerid, healtht);
	if(healtht <= 0)
	{
    	GivePlayerCash(playerid, -5);
		SendClientMessage(playerid, COLOR_ORANGE, "Paramedics saved you for 5 dollars.");
		KillTimer(deatht[playerid]);
	}
	return 1;
}
Reply
#2

Just add a check to see if player is alive or dead. If is dead, execute your code.
Reply
#3

Quote:
Originally Posted by Longover
Посмотреть сообщение
Help.

Problem: When player is spawning then he is connecting on the server,the player give the message "Paramedics saved you for 5 dollars."

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	deatht[playerid] = SetTimerEx("DeathTimer", 1500, 0, "i", playerid);

Код:
public DeathTimer(playerid)
{
	new Float:healtht;
	GetPlayerHealthEx(playerid, healtht);
	if(healtht <= 0)
	{
    	GivePlayerCash(playerid, -5);
		SendClientMessage(playerid, COLOR_ORANGE, "Paramedics saved you for 5 dollars.");
		KillTimer(deatht[playerid]);
	}
	return 1;
}
post your onplayerspawn
Reply
#4

Quote:
Originally Posted by BornHuman
Посмотреть сообщение
post your onplayerspawn
Код:
public OnPlayerSpawn(playerid)
{
	SetPlayerHealthEx(playerid, 100);
	SetPlayerArmourEx(playerid, 0);
	TextDrawShowForPlayer(playerid, Time);
	TextDrawShowForPlayer(playerid, Date);
	SetPlayerWantedLevel(playerid, PlayerInfo[playerid][pWantedLevel]);
	DestroyDynamic3DTextLabel(WantedScris[playerid]);
	if(PlayerInfo[playerid][pWantedLevel] >= 1)
	{
		Tigaanel[playerid] = 1;
		DestroyDynamic3DTextLabel(WantedScris[playerid]);
		new str2[256];
		format(str2,sizeof(str2),"{FF00FF}Nivel de urmarire: %d", PlayerInfo[playerid][pWantedLevel]);
		WantedScris[playerid] = CreateDynamic3DTextLabel(str2, COLOR_WHITE, 0, 0, -20, 20, playerid);
		Streamer_SetFloatData(STREAMER_TYPE_3D_TEXT_LABEL, WantedScris[playerid] , E_STREAMER_ATTACH_OFFSET_Z, 0.48);
	}
	DestroyDynamic3DTextLabel(DeadScris[playerid]);
	if(PlayerInfo[playerid][pWantedLevel] >= 1)
	{
		new str1[256];
		PlayerTextDrawShow(playerid, WantedText[playerid]);
		format(str1,sizeof(str1),"Urmarirea scade in: ~r~%d minute",wantedlost[playerid]/60+1);
		PlayerTextDrawSetString(playerid, WantedText[playerid], str1);
	}
	SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
	if(OnDuty[playerid] > 0)
	{
		if(PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 1)
		{
			GivePlayerWeaponEx(playerid, 24, 500);
			GivePlayerWeaponEx(playerid, 3, 1);
			GivePlayerWeaponEx(playerid, 41, 500);
			GivePlayerWeaponEx(playerid, 29, 1000);
			GivePlayerWeaponEx(playerid, 31, 1000);
			SetPlayerArmourEx(playerid, 100);
			SetPlayerHealthEx(playerid, 100);
		}
		if(PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pLeader] == 2)
		{
			GivePlayerWeaponEx(playerid, 24, 500);
			GivePlayerWeaponEx(playerid, 3, 1);
			GivePlayerWeaponEx(playerid, 41, 500);
			GivePlayerWeaponEx(playerid, 29, 1000);
			GivePlayerWeaponEx(playerid, 31, 1000);
			SetPlayerArmourEx(playerid, 100);
			SetPlayerHealthEx(playerid, 100);
		}
		if(PlayerInfo[playerid][pMember] == 3 || PlayerInfo[playerid][pLeader] == 3)
		{
			GivePlayerWeaponEx(playerid, 24, 500);
			GivePlayerWeaponEx(playerid, 41, 500);
			GivePlayerWeaponEx(playerid, 29, 1000);
			GivePlayerWeaponEx(playerid, 31, 1000);
			SetPlayerArmourEx(playerid, 100);
			SetPlayerHealthEx(playerid, 100);
		}
		if(PlayerInfo[playerid][pMember] == 8 || PlayerInfo[playerid][pLeader] == 8)
		{
			GivePlayerWeaponEx(playerid, 24, 500);
			GivePlayerWeaponEx(playerid, 3, 1);
			GivePlayerWeaponEx(playerid, 41, 500);
			GivePlayerWeaponEx(playerid, 29, 1000);
			GivePlayerWeaponEx(playerid, 31, 1000);
			SetPlayerArmourEx(playerid, 100);
			SetPlayerHealthEx(playerid, 100);
		}
	}
	if(!gPlayerAnimLibsPreloaded[playerid])
	{
		PreloadAnimLib(playerid,"BOMBER");
		PreloadAnimLib(playerid,"RAPPING");
		PreloadAnimLib(playerid,"SHOP");
		PreloadAnimLib(playerid,"BEACH");
		PreloadAnimLib(playerid,"SMOKING");
		PreloadAnimLib(playerid,"FOOD");
		PreloadAnimLib(playerid,"ON_LOOKERS");
		PreloadAnimLib(playerid,"DEALER");
		PreloadAnimLib(playerid,"MISC");
		PreloadAnimLib(playerid,"SWEET");
		PreloadAnimLib(playerid,"RIOT");
		PreloadAnimLib(playerid,"PED");
		PreloadAnimLib(playerid,"POLICE");
		PreloadAnimLib(playerid,"CRACK");
		PreloadAnimLib(playerid,"CARRY");
		PreloadAnimLib(playerid,"COP_AMBIENT");
		PreloadAnimLib(playerid,"PARK");
		PreloadAnimLib(playerid,"INT_HOUSE");
		PreloadAnimLib(playerid,"FOOD");
		gPlayerAnimLibsPreloaded[playerid] = 1;
	}
	gTeam[playerid] = PlayerInfo[playerid][pTeam];
	if(gTeam[playerid] == 4)
	{
		gTeam[playerid] = 4;
	}
	if(PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 1 || PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pLeader] == 2 || PlayerInfo[playerid][pMember] == 3 || PlayerInfo[playerid][pLeader] == 3 || PlayerInfo[playerid][pMember] == 8 || PlayerInfo[playerid][pLeader] == 8)
	{
		gTeam[playerid] = 2;
		PlayerInfo[playerid][pTeam] = 2;
	}
	if(gPlayerLogged[playerid] == 0)
	{
		SendClientMessage(playerid, COLOR_LIGHTRED, "** Trebuie sa te loghezi inainte de a te spawna (KICK) **");
		Kick(playerid);
		return 1;
	}
	ChosenSkin[playerid] = 1;
	SetPlayerSpawn(playerid);
	SetPlayerToTeamColor(playerid);
	playerdeath[playerid] = 0;
	Undercover[playerid] = 0;
	SetPlayerTeam(playerid,4);
	StopAudioStreamForPlayer(playerid);
	return 1;
}
Reply
#5

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
Just add a check to see if player is alive or dead. If is dead, execute your code.
The check: (timer for a second)
Код:
public DeathTimer(playerid)
{
	new Float:healtht;
	GetPlayerHealthEx(playerid, healtht);
	if(healtht <= 0)
	{
    	GivePlayerCash(playerid, -5);
		SendClientMessage(playerid, COLOR_ORANGE, "Paramedics saved you for 5 dollars.");
		KillTimer(deatht[playerid]);
	}
	return 1;
}
Reply
#6

What i mean is this:

pawn Код:
new IsPlayerDead[MAX_PLAYERS];
OnPlayerDeath:

pawn Код:
IsPlayerDead[playerid] = 1;
Then, always on OnPlayerDeath:

pawn Код:
if(IsPlayerDead[playerid] == 1)
        (
    new Float:healtht;
    GetPlayerHealthEx(playerid, healtht);
    if(healtht <= 0)
    {
        GivePlayerCash(playerid, -5);
        SendClientMessage(playerid, COLOR_ORANGE, "Paramedics saved you for 5 dollars.");
        KillTimer(deatht[playerid]);
    }
        )
To avoid send the message when a player joins.
Reply
#7

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
What i mean is this:

pawn Код:
new IsPlayerDead[MAX_PLAYERS];
OnPlayerDeath:

pawn Код:
IsPlayerDead[playerid] = 1;
Then, always on OnPlayerDeath:

pawn Код:
if(IsPlayerDead[playerid] == 1)
        (
    new Float:healtht;
    GetPlayerHealthEx(playerid, healtht);
    if(healtht <= 0)
    {
        GivePlayerCash(playerid, -5);
        SendClientMessage(playerid, COLOR_ORANGE, "Paramedics saved you for 5 dollars.");
        KillTimer(deatht[playerid]);
    }
        )
To avoid send the message when a player joins.
Hmmm,i must keep the timer,or delete it?
Reply
#8

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
What i mean is this:

pawn Код:
new IsPlayerDead[MAX_PLAYERS];
OnPlayerDeath:

pawn Код:
IsPlayerDead[playerid] = 1;
Then, always on OnPlayerDeath:

pawn Код:
if(IsPlayerDead[playerid] == 1)
        (
    new Float:healtht;
    GetPlayerHealthEx(playerid, healtht);
    if(healtht <= 0)
    {
        GivePlayerCash(playerid, -5);
        SendClientMessage(playerid, COLOR_ORANGE, "Paramedics saved you for 5 dollars.");
        KillTimer(deatht[playerid]);
    }
        )
To avoid send the message when a player joins.
When i compile i give no errors but the .amx is empty.
Reply
#9

Quote:
Originally Posted by Longover
Посмотреть сообщение
When i compile i give no errors but the .amx is empty.
You should get at least this message:

Quote:

Pawn compiler 3.10.8 Copyright © 1997-2006, ITB CompuPhase

Go to your Pawno folder, open pawn.cfg (Or if doesn't exist, create it),add -d3 inside, save and close it.

Then try to recompile.
Reply
#10

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
You should get at least this message:



Go to your Pawno folder, open pawn.cfg (Or if doesn't exist, create it),add -d3 inside, save and close it.

Then try to recompile.
Same.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)