onplayerdeath player still talks
#1

hello guys im preparing a OnPlayerDeath but it doesnt seem to work as when i die i still can talk.here is my code:
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(IsDead[playerid] == 1 && InCall[playerid] == 1 && Tallking[playerid] == 1) IsDead[playerid] = 1;
	new Float:px,Float:py,Float:pz;
	GetPlayerPos(playerid,px,py,pz);
	USER[playerid][DEATHS]=1;
	SendClientMessage(playerid,COLOR_RED, "You Are Brutally Wounded. If You Don't Get Help You Will Die.(/acceptdeath to die)");
	SetPlayerPos(playerid,px,py,pz);
	ApplyAnimation(playerid,"ped","FALL_fall",4.1,1,1,1,0,0,1);
	return 1;
} 
public OnPlayerText(playerid, text[])
{
	if(InCall[playerid] == 1)
    {
 		if(IsPlayerConnected(TallkingID[playerid]) && Tallking[playerid] == 1 && TallkingID[playerid] > -1 && Tallking[TallkingID[playerid]] == 1)
        {
			new str[128];
            format(str,sizeof(str),"[Ph]%s (phone): %s",GetName(playerid),text);
            SendClientMessage(TallkingID[playerid],COLOR_LIGHTGRAY,str);
            format(str,sizeof(str),"[Ph]%s (phone): %s",GetName(playerid),text);
            SendClientMessage(playerid,COLOR_LIGHTGRAY,str);
            ProxDetector(23.0, playerid, str, -1);
            return 0;
		}
  	}
  	else
  	{
		if(USER[playerid][DEATHS]==1) return SendClientMessage(playerid,COLOR_RED,"You Are Brutally Wounded And Can't Talk");
		else
		{
			if(USER[playerid][DEATHS]==0)
			{
	    		new texts[128],name[24];
	    		GetPlayerName(playerid,name,24);
	    		format(texts,sizeof(texts), "%s: %s",name,text);
	    		ProxDetector(23.0, playerid, texts, -1);
	    		return 0;
			}
		}
	}
	    return 0;
}
Any help is appreciated
Reply
#2

why you use else ?
use
else if ()
or
if() alone

and also with this script players can talk in call to xD
Reply
#3

changed my code to:
Код:
public OnPlayerText(playerid, text[])
{
	if(InCall[playerid] == 1)
    {
 		if(IsPlayerConnected(TallkingID[playerid]) && Tallking[playerid] == 1 && TallkingID[playerid] > -1 && Tallking[TallkingID[playerid]] == 1)
        {
			new str[128];
            format(str,sizeof(str),"[Ph]%s (phone): %s",GetName(playerid),text);
            SendClientMessage(TallkingID[playerid],COLOR_LIGHTGRAY,str);
            format(str,sizeof(str),"[Ph]%s (phone): %s",GetName(playerid),text);
            SendClientMessage(playerid,COLOR_LIGHTGRAY,str);
            ProxDetector(23.0, playerid, str, -1);
            return 0;
		}
  	}
	if(USER[playerid][DEATHS]==1) return SendClientMessage(playerid,COLOR_RED,"You Are Brutally Wounded And Can't Talk");
	if(USER[playerid][DEATHS]==0)
		{
	    	new texts[128],name[24];
	    	GetPlayerName(playerid,name,24);
	    	format(texts,sizeof(texts), "%s: %s",name,text);
	    	ProxDetector(23.0, playerid, texts, -1);
	    	return 0;
		}
	return 0;
}
still talks when dead
Reply
#4

You really don't have to do this.

Код:
if(USER[playerid][DEATHS]==0)
{
     new texts[128],name[24];
     GetPlayerName(playerid,name,24); 
     format(texts,sizeof(texts), "%s: %s",name,text);
     ProxDetector(23.0, playerid, texts, -1);
     return 0;
}
Add this at the top of OnPlayerText and see if it works:
Код:
if(USER[playerid][DEATHS])
{
     SendClientMessage(playerid,COLOR_RED,"You Are Brutally Wounded And Can't Talk");
}
Reply
#5

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
You really don't have to do this.

Код:
if(USER[playerid][DEATHS]==0)
{
     new texts[128],name[24];
     GetPlayerName(playerid,name,24); 
     format(texts,sizeof(texts), "%s: %s",name,text);
     ProxDetector(23.0, playerid, texts, -1);
     return 0;
}
Add this at the top of OnPlayerText and see if it works:
Код:
if(USER[playerid][DEATHS])
{
     SendClientMessage(playerid,COLOR_RED,"You Are Brutally Wounded And Can't Talk");
}
outcome:
Код:
You Are Brutally Wounded And Can't Talk
chaves:asd
so still can talk
Reply
#6

First of all "DEATHS" is plural so you should use it to store how many times he died and NOT if he's dying now.
Add return 0;

Код:
if(USER[playerid][DEATHS])
{
     SendClientMessage(playerid,COLOR_RED,"You Are Brutally Wounded And Can't Talk");
     return 0;
}
Reply
#7

First of all, your code worked thanks
and second I know deaths is plural but im using it only like if player dies deaths gets equal to 1 and if player is dead he spawns at hospital with acceptdeath again deaths equal to 0 I like to use it that way for my own purposes and thats not the point here
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)