need help with onlyplayergivedamage or takedamage
#1

this is my code ,i want to give kills to the player and give damage to the players in the range and it should show in kill feed

Код:
forward DelayedNuke(playerid);
public DelayedNuke(playerid)
{
	SetWeather(19);
    SendClientMessageToAll(COLOR_MAROON,"[NUKE] Balla's base has been nuked");
    CreateExplosion(2466.5945,-1660.5227,13.2774,6,100.0);
    for(new i = 0; i < MAX_PLAYERS; i ++)
    if(IsPlayerInRangeOfPoint(i,50.0,2466.5945, -1660.5227, 13.2774))
    {
		if(PInfo[i][God] == 1 || PInfo[i][pAdminDuty] == 1)
		return 1;
        GameTextForPlayer(i, "~r~NUKED!",2000,3);
    	SetPlayerHealth(i,0.0);
    	PInfo[i][Nuked] = 1;
    }
    return 1;
}
Reply
#2

What is the problem exactly?
Reply
#3

Quote:
Originally Posted by Extremo
Посмотреть сообщение
What is the problem exactly?
There is no problem with the code,i want to know that how can i give kills to the guy who used nuked and show it in kill feed
Reply
#4

https://sampwiki.blast.hk/wiki/SendDeathMessage
For kills, you will need to show how you use it, or if you can do it yourself ofc.
It might look something like this:
pawn Код:
PInfo[playerid][Kills] ++;
Reply
#5

eh no not that,i mean like

there are players in area where i launched nuke now they are all dead,i want to send message to the player and it will show in kill list

random1,random2,random3

You killed random1
You killed random2
You killed random3
Reply
#6

Add a string on top of the loop, like

pawn Код:
new killed[256];
and in the loop you do the following:

pawn Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(i, name, sizeof(name));
format(killed, sizeof(killed), "%s\n%s", killed, name);
and at the bottom of the loop

pawn Код:
format(killed, sizeof(killed), "You killed the following players: %s", killed);
SendClientMessage(playerwholaunchednuke, color, killed);
I am sure you get the idea
Reply
#7

Since you're creating an explosion, you can check if they're close to it, and if they died by an explosion.
To check if they died by an explosion, you can use OnPlayerDeath.
Just made a simple code here, where you need 2 global variables:
pawn Код:
new NukeActivated;
new NukeIssuer;
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(reason == 51 && NukeActivated == 1 && IsPlayerInRangeOfPoint(playerid, 50.0,2466.5945, -1660.5227, 13.2774)
        // 51 = Explosion reason, and using same coordinates as your nuke IsPlayerInRangeOfPoint
    {
        new string[13 + MAX_PLAYER_NAME];
        format(string, sizeof(string), "You killed %s!");
        SendClientMessage(NukeIssuer, -1, string);
    }
    return 1;
}
Then in your nuke code, set "NukeIssuer" to the playerid that launched it, and set "NukeActivated" to 1.
Then create a short timer, like about 1 second, where you set "NukeActivated" to 0.
Reply
#8

thank you for all your help
Reply


Forum Jump:


Users browsing this thread: