The command!
#1

The command worked succesfully but The problem with Arrested!

If there a player at Los Santos and the Cop In Las Venterus and The cop type /ar 0 he will got arrested!! Why?? I just want it If the cop near Player he can arrest!

PHP код:
CMD:ar(playeridparams[])
{
    if(!
PoliceTeam(GetPlayerSkin(playerid))) return SendClientMessage(playerid0xE74C3CFF"{FF0000}Error: {FFFFFF}Only Law Enforcement may use this command.");
    new 
pName[MAX_PLAYER_NAME],tName[MAX_PLAYER_NAME],targetid,string[128];
    new 
Float:targetidpos[3];
    if(
GetPlayerInterior(targetid) > 0) return SendClientMessage(playeridred"ERROR: You can't arrest players inside an interior.");
    if(
sscanf(params"ui"targetid)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /ar <playerid> / <PlayerName>");
    if(
GetPVarInt(playerid,"ArTime")>GetTickCount())return SendClientMessage(playerid,0xFF0000FF,"Please wait 5 seconds before arresting a suspect again.");
    if(
PlayerInfo[targetid][pJailed] == 1) return SendClientMessage(playeridred"This player is already in jail,you can't arrest him.");
    if(
IsPlayerInAnyVehicle(targetid)) return SendClientMessage(playerid,red,"You can't arrest players if they're in a vehicle.");
    if(
GetPlayerWantedLevel(targetid) <= 3) return SendClientMessage(playeridred"ERROR: You can't arrest players with wanted level lower than 4.Use /tk to issue a ticket,or press 2.");
    if(
GetPlayerWantedLevel(targetid) == 0) return SendClientMessage(playeridred"This player is not wanted,you can't arrest him");
    if(
playerid == targetid) return SendClientMessage(playerid,red"You can't arrest yourself,you stupid or what?");
    
GetPlayerPos(playeridtargetidpos[0], targetidpos[1], targetidpos[2]);
    if (!
IsPlayerInRangeOfPoint(playerid5.0targetidpos[0], targetidpos[1], targetidpos[2])) return SendClientMessage(playerid, -1"Nobody close enough to arrest.");
    
GetPlayerName(playeridpNamesizeof(pName));
    
GetPlayerName(targetidtNamesizeof(tName));
    if(
IsPlayerConnected(targetid))
        {
            if(
GetPlayerWantedLevel(targetid) >= 4)
            {
                
SetTimerEx("JailPlayer",5000,0,"i",targetid);// making 5 sec timer for jail
                 
SetPlayerAttachedObject(targetid9194186, -0.0110000.028000, -0.022000, -15.600012, -33.699977, -81.7000350.8919991.0000001.168000);
                
SetPlayerSpecialAction(targetidSPECIAL_ACTION_CUFFED);
                
ApplyAnimation(playerid"ped""ARRESTgun"4.101111);
                new 
ArrestReward random(10000) + 2500;
                if(
ArrestReward GetPlayerMoney(playerid))
                
                
SendClientMessage(targetidred"{0080FF}[BEING ARRESTED]: {FFFFFF}Law Enforcement Officer has put {ADFF2F}Handcuffs {FFFFFF}on you.");
                
                
format(stringsizeof(string), "{ffffff}You have Arrested {FFD700}%s(%d){FFFFFF}. You have received {33FF33}$%d {FFFFFF}for this Arrest."tNametargetidArrestReward);
                
SendClientMessage(playeridredstring);
                
                
format(stringsizeof(string), "You have placed {0080FF}%s(%d) {FFFFFF}in Handcuffs for an Arrest. Use {0080FF}/search (id) {FFFFFF}to search Him for illegal Drugs."tNametargetid);
                
SendClientMessage(targetidredstring);
                
                
format(stringsizeof(string), "{0080FF}[ARRESTED]: {FFD700}%s(%d) {FFFFFF}has been {33CCFF}Arrested {FFFFFF}by {308AFF}Officer %s(%d){FFFFFF}!"tNametargetidpNameplayerid);
                
SendClientMessageToAll(yellowstring);
                
format(stringsizeof(string), "~w~You have ~G~Arrested ~Y~%s(%d)~n~n~You have received ~n~n~~y~$%d ~w~for this Arrest."tNametargetidArrestReward);
                
GameTextForPlayer(playeridstring70005);
                
GivePlayerMoney(playeridArrestReward);
                
GivePlayerMoney(targetid, -ArrestReward);
                
SetPlayerScore(playeridGetPlayerScore(playerid)+1);
                
SetPlayerScore(targetidGetPlayerScore(targetid)-1);
                
SetPVarInt(playerid,"ArTime",GetTickCount()+5000);
                }
                }
                return 
1;

Reply
#2

You don't check the position of the cop.
Reply
#3

Here are the funcations, you just do the rest in your code.

Код:
function IsNearPlayer(playerid, targetid) {
	new Float: Coordss[3];
	GetPlayerPos(playerid, Coordss[0], Coordss[1], Coordss[2]);
    if(IsPlayerInRangeOfPoint(targetid, 20.0, Coordss[0], Coordss[1], Coordss[2]) && (GetPlayerVirtualWorld(targetid) == GetPlayerVirtualWorld(playerid))) return 1;
	return 0;
}

function IsNearPlayer2(Float:range, playerid, targetid) {
	new Float: Coordss[3];
    GetPlayerPos(playerid, Coordss[0], Coordss[1], Coordss[2]);
    if(IsPlayerInRangeOfPoint(playerid, range, Coordss[0], Coordss[1], Coordss[2]) && (GetPlayerVirtualWorld(targetid) == GetPlayerVirtualWorld(playerid))) return 1;
	return 0;
}
Reply
#4

The command was worked!! but After I've adding the texts on the command The bug turn on lol!!

PHP код:
SendClientMessage(targetidred"{0080FF}[BEING ARRESTED]: {FFFFFF}Law Enforcement Officer has put {ADFF2F}Handcuffs {FFFFFF}on you."); 
                 
                
format(stringsizeof(string), "{ffffff}You have Arrested {FFD700}%s(%d){FFFFFF}. You have received {33FF33}$%d {FFFFFF}for this Arrest."tNametargetidArrestReward); 
                
SendClientMessage(playeridredstring); 
                 
                
format(stringsizeof(string), "You have placed {0080FF}%s(%d) {FFFFFF}in Handcuffs for an Arrest. Use {0080FF}/search (id) {FFFFFF}to search Him for illegal Drugs."tNametargetid); 
                
SendClientMessage(targetidredstring); 
                 
                
format(stringsizeof(string), "{0080FF}[ARRESTED]: {FFD700}%s(%d) {FFFFFF}has been {33CCFF}Arrested {FFFFFF}by {308AFF}Officer %s(%d){FFFFFF}!"tNametargetidpNameplayerid); 
                
SendClientMessageToAll(yellowstring); 
                
format(stringsizeof(string), "~w~You have ~G~Arrested ~Y~%s(%d)~n~n~You have received ~n~n~~y~$%d ~w~for this Arrest."tNametargetidArrestReward); 
                
GameTextForPlayer(playeridstring70005); 
After add this texts the bug is ON! If I remove them It will be work
Reply
#5

Help
Reply
#6

You want to look at this section...

Код:
new ArrestReward = random(10000) + 2500; 
                if(ArrestReward > GetPlayerMoney(playerid))
You check if the reward is more than what the player has, yet do nothing with it...

It's also above where that stoppage is, and it could have something to do with it... Try put more money on the player, or less...
Reply
#7

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
You want to look at this section...

Код:
new ArrestReward = random(10000) + 2500; 
                if(ArrestReward > GetPlayerMoney(playerid))
You check if the reward is more than what the player has, yet do nothing with it...

It's also above where that stoppage is, and it could have something to do with it... Try put more money on the player, or less...
This faction only for cop if the cop arrest someone he will got a reward what's wrong with it?
Reply
#8

So the if statement has something to do with them getting a reward?


Just saying, the if statement does nothing at all, yet your issue, mysteriously starts just after there, so because of that, you should be looking there...
Reply
#9

I'm sorry but I'm not understand you! can you edit the code What I've posting? Thank you
Reply
#10

Have you even tried modifying it? After all, if you're looking for help, wouldn't you be looking for the issue, rather than questioning what people are questioning you on?


You've got single line if statements, which work, you've got normal if statements that work, then you have this one that has a simple if statement, no braces, and no functions on it's line, and it doesn't work...




Doesn't take much of a rocket scientist to actually look at where something is occurring, and tracking back to what is above it in the code...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)