PDA

View Full Version : Damage!


Thanks
22/07/2018, 01:19 AM
Hi I want to do.. If someone trying to arrest a player and the enemy player are shooted the cops! the police cannot arrested him he must wait untill he don't taking a damage from the player Example: [WARRING]: You cannot arrested this player while you taking a damage from him... How to do that..


This is a command /ar

CMD:ar(playerid, params[])
{
new pName[MAX_PLAYER_NAME],tName[MAX_PLAYER_NAME],targetid,string[128];
new Float:targetidpos[3];
if(!PoliceTeam(GetPlayerSkin(playerid)) && !SWAT(GetPlayerSkin(playerid)) && !Army(GetPlayerSkin(playerid)) && !FBII(GetPlayerSkin(playerid)) && !CIA(GetPlayerSkin(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "{FF0000}Error: {FFFFFF}Only Law Enforcement may use this command.");
if(GetPlayerInterior(targetid) > 0) return SendClientMessage(playerid, red, "{FF0000}Error: You can't arrest players inside an interior.");
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, "{FF0000}Error: /arrest <playerid> / <PlayerName>");
if(GetPVarInt(playerid,"ArTime")>GetTickCount())return SendClientMessage(playerid,0xFF0000FF,"{FF0000}Error: Please wait 5 seconds before arresting a suspect again.");
if(PlayerInfo[targetid][pJailed] == 1) return SendClientMessage(playerid, red, "{FF0000}Error: This player is already in jail, you can't arrest them.");
if(IsPlayerInAnyVehicle(targetid)) return SendClientMessage(playerid,red,"{FF0000}Error: You can't arrest players if they're in a vehicle.");
if(GetPlayerWantedLevel(targetid) <= 3) return SendClientMessage(playerid, red, "{FF0000}Error: You can't arrest players with a wanted level lower than 4. Use /tk to issue a ticket, or press 2.");
if(GetPlayerWantedLevel(targetid) == 0) return SendClientMessage(playerid, red, "{FF0000}Error: This player is not wanted, you can't arrest them");
if(playerid == targetid) return SendClientMessage(playerid,red, "{ff0000}Error: {ffffff}You can't arrest yourself.");
GetPlayerPos(playerid, targetidpos[0], targetidpos[1], targetidpos[2]);
if (!IsPlayerInRangeOfPoint(playerid, 5.0, targetidpos[0], targetidpos[1], targetidpos[2])) return SendClientMessage(playerid, -1, "Error: Nobody close enough to arrest.");
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerName(targetid, tName, sizeof(tName));
if(IsPlayerConnected(targetid))
{
if(SWAT(GetPlayerSkin(playerid)))
{
if(GetPlayerWantedLevel(targetid) >= 4)
{
SecondsToJail[targetid] = SetTimerEx("JailPlayer",5000,0,"i",targetid);
TryingArrested[playerid] = 1;
ArrestingPlayer[targetid] = playerid;
format(string, sizeof(string), "{0080FF}[BEING ARRESTED]: {FFFFFF}S.W.A.T AGENT %s(%d) has put {ADFF2F}handcuffs {FFFFFF}on you.", pName, playerid);
SendClientMessage(targetid, red, string);
SetPlayerAttachedObject(targetid, 9, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
format(string, sizeof(string), "~W~AN ~B~S.W.A.T AGENT %s(%d) ~W~HAS CUFFED YOU!!~n~~b~TYPE [/BC] TO ESCAPE FROM THE ~Y~CUFFS", pName, playerid);
GameTextForPlayer(targetid, string, 4000, 5);
format(string, sizeof(string), "{33B5FF}[BEGIN ARREST!!!] S.W.A.T AGENT %s(%d) is trying to arrest you!! {33B5FF}Use /BC for escape from this arrest!!", pName, playerid);
SendClientMessage(targetid, red, string);
format(string, sizeof(string), "{ffffff}You have placed {0080FF}%s(%d) {FFFFFF}in handcuffs for an arrest. Use {0080FF}/search (id) {FFFFFF}to search them for illegal Drugs.", tName, targetid);
SendClientMessage(playerid, red, string);
SetPVarInt(playerid,"ArTime",GetTickCount()+5000);
return 1;
}
}

coool
22/07/2018, 06:18 AM
Hello,
Take a look at OnPlayerGiveDamage... Check if the player who has took damage is a cop.. and then assign the cop a variable (so you can check if he is taking damage in /ar command.) Then put a timer after the timer ends reset the variable from the cop..

+rep

Thanks
22/07/2018, 04:02 PM
Can you give me example code? Ty

Thanks
23/07/2018, 02:03 AM
anyone help me?

Thanks
23/07/2018, 04:26 AM
Hello,
Take a look at OnPlayerGiveDamage... Check if the player who has took damage is a cop.. and then assign the cop a variable (so you can check if he is taking damage in /ar command.) Then put a timer after the timer ends reset the variable from the cop..

+rep

Extacly! But I really need your help to give me a example to do that! So can you give me some examples? Thanks! Anyone?

coool
23/07/2018, 05:34 AM
Hello,
Take a look at OnPlayerGiveDamage... Check if the player who has took damage is a cop.. and then assign the cop a variable (so you can check if he is taking damage in /ar command.) Then put a timer after the timer ends reset the variable from the cop..

+rep
You just have to change the above from English Language to Pawn!
Take a look at OnPlayerGiveDamage/OnPlayerTakeDamage
public OnPlayerTakeDamage(playerid, issuerid, amount, weaponid, bodypart)
{
return 1;
}

Check if the player who has took damage is a cop..
if (playerid == cop) //cop is the var in which you store player's faction.
and then assign the cop a variable
PlayerHasTakenDamage[playerid] = issuerid; //this variable must be globally declared.
so you can check if he is taking damage in /ar command.
CMD:ar(playerid, params[])
{
//All the check etc.
if (PlayerHasTakenDamage[playerid] == targetid) return SendClientMessage(playerid, -1, "You can not arrest him.");
}
Then put a timer after the timer ends reset the variable from the cop..
//Go back to the callback.
public OnPlayerTakeDamage(playerid, issuerid, amount, weaponid, bodypart)
{
if (playerid == cop) //previous code
{
PlayerHasTakenDamage[playerid] = issuerid;//Preivous code
SetTimerEx("ResetDmgVar", time, false, "i", playerid); //timer
}
return 1;
}
forward ResetDmgVar(playerid);
public ResetDmgVar(playerid)
{
PlayerHasTakenDamage[playerid] = -1; //variable reset
}
Can you give me example code? Ty
Shown It.

P.S You can only bump a thread after 24 hours.