Public for player hit?
#1

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.
Reply
#2

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

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.
Reply
#4

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?
Reply
#5

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
Reply
#6

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?)
Reply
#7

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..?
Reply
#8

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.
Reply
#9

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)?
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)