SA-MP Forums Archive
Public for player hit? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Public for player hit? (/showthread.php?tid=480960)



Public for player hit? - tamirshoval - 13.12.2013

Hello.
So is that a way to like give a star to a guy who hited someone? (Then the police will come,but i will script that)
which public do i need?
Not player died,player hited
thanks.


Re: Public for player hit? - Kyance - 13.12.2013

Either
https://sampwiki.blast.hk/wiki/OnPlayerGiveDamage
Or
https://sampwiki.blast.hk/wiki/OnPlayerTakeDamage


Re: Public for player hit? - erminpr0 - 13.12.2013

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
Be sure you know how to use it, because of lagg, is not 100% synced.
There are some fixes, Search

EDIT: Kyance posted while I was typing.


Re: Public for player hit? - tamirshoval - 13.12.2013

Quote:
Originally Posted by erminpr0
Посмотреть сообщение
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
Be sure you know how to use it, because of lagg, is not 100% synced.
There are some fixes, Search

EDIT: Kyance posted while I was typing.
Umm,So how do i do that when the player get damage,the police (Police = 2) Will know?


Re: Public for player hit? - Kyance - 13.12.2013

Quote:
Originally Posted by tamirshoval
Посмотреть сообщение
Umm,So how do i do that when the player get damage,the police (Police = 2) Will know?
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID) // If not self-inflicted
    {
        new
            infoString[128],
            weaponName[24],
            victimName[MAX_PLAYER_NAME],
            attackerName[MAX_PLAYER_NAME];
 
        GetPlayerName(playerid, victimName, sizeof (victimName));
        GetPlayerName(issuerid, attackerName, sizeof (attackerName));
 
        format(infoString, sizeof(infoString),  "[DISPATCH] - %s has attacked %s | weapon: %s | damage: %.0f |", attackerName, victimName, weaponName, amount);
        //Command that will send the message to the cops, for an ex: SendMessageToCops, or w.e you have!
       SetPlayerWantedLevel(issuerid, GetPlayerWantedLevel(issuerid) +1); //This will set the players(attackers, issuers) wanted level to +1, when he has attacked somebody
       }
     return 1;
}
Not tested.. xd
EDIT: Added the
SetPlayerWantedLevel(issuerid, GetPlayerWantedLevel(issuerid) +1); //This will set the players(attackers, issuers) wanted level to +1, when he has attacked somebody


Re: Public for player hit? - tamirshoval - 13.12.2013

Quote:
Originally Posted by Kyance
Посмотреть сообщение
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID) // If not self-inflicted
    {
        new
            infoString[128],
            weaponName[24],
            victimName[MAX_PLAYER_NAME],
            attackerName[MAX_PLAYER_NAME];
 
        GetPlayerName(playerid, victimName, sizeof (victimName));
        GetPlayerName(issuerid, attackerName, sizeof (attackerName));
 
        format(infoString, sizeof(infoString),  "[DISPATCH] - %s has attacked %s | weapon: %s | damage: %.0f |", attackerName, victimName, weaponName, amount);
        //Command that will send the message to the cops, for an ex: SendMessageToCops, or w.e you have!
       }
     return 1;
}
Not tested.. xd
Ok,but shouldnt i add the var of the Police (if police = 2 they will see it?)


Re: Public for player hit? - Kyance - 13.12.2013

Quote:
Originally Posted by tamirshoval
Посмотреть сообщение
Ok,but shouldnt i add the var of the Police (if police = 2 they will see it?)
Uh, what do you mean?

By the way, in-case you didn't notice, i updated it.
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID) // If not self-inflicted
    {
        new
            infoString[128],
            weaponName[24],
            victimName[MAX_PLAYER_NAME],
            attackerName[MAX_PLAYER_NAME];
 
        GetPlayerName(playerid, victimName, sizeof (victimName));
        GetPlayerName(issuerid, attackerName, sizeof (attackerName));
 
        format(infoString, sizeof(infoString),  "[DISPATCH] - %s has attacked %s | weapon: %s | damage: %.0f |", attackerName, victimName, weaponName, amount);
        //Command that will send the message to the cops, for an ex: SendMessageToCops, or w.e you have!
        SetPlayerWantedLevel(issuerid, GetPlayerWantedLevel(issuerid) +1); //This will set the players(attackers, issuers) wanted level to +1, when he has attacked somebody
       }
     return 1;
}
But still, it's not tested.
Is the "var of the Police" the thing ,that allows cops to see the message? For an example - Cop Radio, Robberies etc..?


Re: Public for player hit? - Kyance - 13.12.2013

Well, I'm not sure really..
Could you explain what does the "if(Police[playerid] == 2)" mean?
Does it mean, that the playerid is a cop?
Well, if that's the case, then it wouldn't send the attack(Dispatch) message to the cops, cause the message needs a "SendClientMessage ..."
You can try "SendClientMessageToAll(-1, string);"
That will send the "DISPATCH" message to everyone on the server.


Re: Public for player hit? - tamirshoval - 13.12.2013

Quote:
Originally Posted by Kyance
Посмотреть сообщение
Well, I'm not sure really..
Could you explain what does the "if(Police[playerid] == 2)" mean?
Does it mean, that the playerid is a cop?
Well, if that's the case, then it wouldn't send the attack(Dispatch) message to the cops, cause the message needs a "SendClientMessage ..."
You can try "SendClientMessageToAll(-1, string);"
That will send the "DISPATCH" message to everyone on the server.
yes,it means if the player is a cop.
But if i will use SendClientMessage They wont see the attacker name and deatils right?
So is that posibole for telling them the loaction (Like,Idlewood)?


Re: Public for player hit? - Kyance - 13.12.2013

Quote:
Originally Posted by tamirshoval
Посмотреть сообщение
yes,it means if the player is a cop.
But if i will use SendClientMessage They wont see the attacker name and deatils right?
So is that posibole for telling them the loaction (Like,Idlewood)?
SendClientMessage would be like
"SendClientMessage(attackerName, COLOR, string);" or "SendClientMessage(victimName, COLOR, string);"(Those were just examples)
So either the attacker or the victim would see it.

Do you have a stock or a callback, or anything, that allows cops to have a "Special" chat, or anything that sends a message only to cops?

About the location - I'm personally not that good, but it is possible..
I don't know how to create it, but either it's with "IsPlayerInRangeIfPoint", or something else, not sure :\

And about that "Police[playerid] == 2"
But what do you want to do with the Police[playerid] afterwards?

Do you want it, so the cops get that message only if a cop is being attacked?
If you want that, then you would need to do this i guess -

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID) // If not self-inflicted
    {
        new
            infoString[128],
            weaponName[24],
            victimName[MAX_PLAYER_NAME],
            attackerName[MAX_PLAYER_NAME];

        GetPlayerName(playerid, victimName, sizeof (victimName));
        GetPlayerName(issuerid, attackerName, sizeof (attackerName));

        if(Police[playerid] == 2)//If the victim is a cop
        {
        format(infoString, sizeof(infoString),  "[DISPATCH] - %s has attacked %s | weapon: %s | damage: %.0f |", attackerName, victimName, weaponName, amount);//This message is being formated
        //Command that will send the message to the cops, for an ex: SendMessageToCops, or w.e you have!
        SetPlayerWantedLevel(issuerid, GetPlayerWantedLevel(issuerid) +1);//This will set the players(attackers, issuers) wanted level to +1, when he has attacked somebody
        }
        }
     return 1;
}

It's getting kinda late, so sorry, but i need to go off, try calling somebody else like "Danishaq, Konstantinos or Wizzy", well, those are the people who i trust the most :d