What's wrong with this command?
#1

Hello I've some problem I've making a command for when someone be arrested he can use /bc but the problem is:

After someone by being arrested and using /bc They will tell him in the message Example: Rock(0) has been arrested by S.W.A.T Rock(0) They are choosing the same names in row! I don't know why BUT I need using a CIVILAN NAME and Police NAME name What's wrong? help me

PHP код:
CMD:breakcuff(playeridparams[])
{
    if(
PoliceTeam(GetPlayerSkin(playerid))) return SendClientMessage(playerid, -1"{FF0000}[NayaBOT]: {FFFFFF}You cannot use this command.");
    {
        new 
pName[MAX_PLAYER_NAME],tName[MAX_PLAYER_NAME],targetid;
        new 
string[170], ArrestReward random(15000) + 2500;
        if(
TryingArrested[targetid] == && Civilian(GetPlayerSkin(targetid)))
        {
            switch(
random(100))
            {
                case 
0..35:
                {
                    
GetPlayerName(targetidtNamesizeof(tName));
                    
KillTimer(SecdonsToJail[targetid]);
                    
TryingArrested[targetid] = 0;
                    
SetPlayerWantedLevel(targetid3);
                    
SetPlayerColor(targetidCOLOR_YELLOW);
                    
format(string,sizeof(string), "{808000}%s(%d) {FFFFFF}has {808000}escaped {FFFFFF}from his HANDCUFFS!! {808000}(Being Arrested)"tName,targetid);
                    
SendClientMessageToAll(-1string);
                    
GameTextForPlayer(targetid"~g~ESCAPED ~W~FROM ~R~ARRESTED!!"50005);
                }
                case 
36..100:
                {
                    if(
ArrestReward GetPlayerCash(playerid))
                    
GetPlayerName(targetidtNamesizeof(tName));
                    
GetPlayerName(playeridtNamesizeof(tName));
                    
TryingArrested[targetid] = 0;
                    
ResetPlayerWeapons(targetid);
                    
                    
format(stringsizeof(string), "{808000}%s(%d) {ffffff}has been {808000}ARRESTED {ffffff}by {00FFFF}S.W.A.T %s(%d){ffffff}!! Wanted Level: {00FFFF}%d."tName,targetidpName,playerid,GetPlayerWantedLevel(targetid));
                      
SendClientMessageToAll(yellowstring);
                      
                      
format(stringsizeof(string), "~y~ARRESTED BY %s(%d)~n~~W~YOU LOST ~R~$%d"pNameplayerid, -ArrestReward);
                    
GameTextForPlayer(targetidstring40005);
                    
                    
format(stringsizeof(string), "~g~ARRESTED ~y~%s(%d)~n~~W~YOU GOT ~R~$%d"tNametargetidArrestReward);
                    
GameTextForPlayer(playeridstring40005);
                    
                    
format(stringsizeof(string), "{808000}%s(%d) {ffffff}has {ff0000}failed {ffffff}to escaped from his Handcuffs!! {808000}(Being Arrested)"tName,targetid);
                    
SendClientMessageToAll(yellowstring);
                    
                    
GivePlayerMoney(targetid, -ArrestReward);
                    
GivePlayerMoney(playeridArrestReward);
                }
            }
        }
        else 
SendClientMessage(playerid, -1"{FF0000}Error: {FFFFFF}You can use this command only while being cuffed or arrested.");
    }
    return 
1;

Reply
#2

The problem is in here..

PHP код:
GetPlayerName(targetidtNamesizeof(tName));
                    
GetPlayerName(playeridtNamesizeof(tName)); 
You stored targetid's name in "tName" and stored also playerid's name in "tName"!

Try using this..
PHP код:
GetPlayerName(targetidtNamesizeof(tName));
                    
GetPlayerName(playeridpNamesizeof(tName)); 
Reply
#3

I'm trying to do it like that but it's not work too!!

Код:
GetPlayerName(targetid, tName, sizeof(tName));
		    		GetPlayerName(playerid, pName, sizeof(pName));
why?
Reply
#4

Absolutely it won't work mate.. Because you didn't even enter a variable inside "targetid" So it will count as 0, So it will always show u that the target is ID 0... So your system is messed up.
Reply
#5

So what I can to do? can u edit my code below?
Reply
#6

Use sscanf to assign targetid to whatever the user is typing in. Make sure you understand this, also you have a grammar issue in the script in your timer but I haven't changed it.

PHP код:
CMD:breakcuff(playeridparams[]) 

    if(
PoliceTeam(GetPlayerSkin(playerid))) return SendClientMessage(playerid, -1"{FF0000}[NayaBOT]: {FFFFFF}You cannot use this command."); 
    {
        new 
pName[MAX_PLAYER_NAME],tName[MAX_PLAYER_NAME],targetid,string[170], ArrestReward random(15000) + 2500;
        if (
sscanf(params"u"targetid))
            return 
SendClientMessage(playerid, -1"{FF0000}[NayaBOT]: {FFFFFF}/breakcuffs [playerid/name]");
        if (
targetid == INVALID_PLAYER_ID || !IsPlayerNearPlayer(playeridtargetid6.0))
        return 
SendClientMessage(playerid, -1"{FF0000}[NayaBOT]: {FFFFFF}The specified player is disconnected or not near you.");
        if(
TryingArrested[targetid] == && Civilian(GetPlayerSkin(targetid))) 
        { 
            switch(
random(100)) 
            { 
                case 
0..35
                { 
                    
GetPlayerName(targetidtNamesizeof(tName)); 
                    
KillTimer(SecdonsToJail[targetid]); 
                    
TryingArrested[targetid] = 0
                    
SetPlayerWantedLevel(targetid3); 
                    
SetPlayerColor(targetidCOLOR_YELLOW); 
                    
format(string,sizeof(string), "{808000}%s(%d) {FFFFFF}has {808000}escaped {FFFFFF}from his HANDCUFFS!! {808000}(Being Arrested)"tName,targetid); 
                    
SendClientMessageToAll(-1string); 
                    
GameTextForPlayer(targetid"~g~ESCAPED ~W~FROM ~R~ARRESTED!!"50005); 
                } 
                case 
36..100
                { 
                    if(
ArrestReward GetPlayerCash(playerid)) 
                    
GetPlayerName(targetidtNamesizeof(tName)); 
                    
GetPlayerName(playeridpNamesizeof(pName)); 
                    
TryingArrested[targetid] = 0
                    
ResetPlayerWeapons(targetid); 
                     
                    
format(stringsizeof(string), "{808000}%s(%d) {ffffff}has been {808000}ARRESTED {ffffff}by {00FFFF}S.W.A.T %s(%d){ffffff}!! Wanted Level: {00FFFF}%d."tName,targetidpName,playerid,GetPlayerWantedLevel(targetid)); 
                    
SendClientMessageToAll(yellowstring); 
                       
                    
format(stringsizeof(string), "~y~ARRESTED BY %s(%d)~n~~W~YOU LOST ~R~$%d"pNameplayerid, -ArrestReward); 
                    
GameTextForPlayer(targetidstring40005); 
                     
                    
format(stringsizeof(string), "~g~ARRESTED ~y~%s(%d)~n~~W~YOU GOT ~R~$%d"tNametargetidArrestReward); 
                    
GameTextForPlayer(playeridstring40005); 
                     
                    
format(stringsizeof(string), "{808000}%s(%d) {ffffff}has {ff0000}failed {ffffff}to escaped from his Handcuffs!! {808000}(Being Arrested)"tName,targetid); 
                    
SendClientMessageToAll(yellowstring); 
                     
                    
GivePlayerMoney(targetid, -ArrestReward); 
                    
GivePlayerMoney(playeridArrestReward); 
                } 
            } 
        } 
        else 
SendClientMessage(playerid, -1"{FF0000}Error: {FFFFFF}You can use this command only while being cuffed or arrested."); 
    } 
    return 
1

Reply
#7

No because it's nothing from the command itself, You should do something like.. An array defined globally that stores the ID of the player getting arrested, so you can use this array instead of "targetid".. Example:

You can create either an array or an enum..

PHP код:
enum pinfo
{
     
pArresting
}

new 
PlayerInfo[MAX_PLAYERS][pinfo]; 
or an array..

PHP код:
new ArrestingPlayer[MAX_PLAYERS]; 
PHP код:
cmd:arrest(playeridparams[])
{
      new 
targetid;
      if(
sscanf(params"u"targetid)) return SendClientMessage(playeridCOLOR_RED"/arrest [target]");
      
ArrestingPlayer[playerid] = targetid;

or
PHP код:
cmd:arrest(playeridparams[])
{
      new 
targetid;
      if(
sscanf(params"u"targetid)) return SendClientMessage(playeridCOLOR_RED"/arrest [target]");
      
PlayerInfo[playerid][pArresting] = targetid;

and instead of using "targetid" in the "/bc" command, use the enum or the array..
Reply
#8

Quote:
Originally Posted by Tass007
Посмотреть сообщение
Use sscanf to assign targetid to whatever the user is typing in. Make sure you understand this, also you have a grammar issue in the script in your timer but I haven't changed it.

PHP код:
CMD:breakcuff(playeridparams[]) 

    if(
PoliceTeam(GetPlayerSkin(playerid))) return SendClientMessage(playerid, -1"{FF0000}[NayaBOT]: {FFFFFF}You cannot use this command."); 
    {
        new 
pName[MAX_PLAYER_NAME],tName[MAX_PLAYER_NAME],targetid,string[170], ArrestReward random(15000) + 2500;
        if (
sscanf(params"u"targetid))
            return 
SendClientMessage(playerid, -1"{FF0000}[NayaBOT]: {FFFFFF}/breakcuffs [playerid/name]");
        if (
targetid == INVALID_PLAYER_ID || !IsPlayerNearPlayer(playeridtargetid6.0))
        return 
SendClientMessage(playerid, -1"{FF0000}[NayaBOT]: {FFFFFF}The specified player is disconnected or not near you.");
        if(
TryingArrested[targetid] == && Civilian(GetPlayerSkin(targetid))) 
        { 
            switch(
random(100)) 
            { 
                case 
0..35
                { 
                    
GetPlayerName(targetidtNamesizeof(tName)); 
                    
KillTimer(SecdonsToJail[targetid]); 
                    
TryingArrested[targetid] = 0
                    
SetPlayerWantedLevel(targetid3); 
                    
SetPlayerColor(targetidCOLOR_YELLOW); 
                    
format(string,sizeof(string), "{808000}%s(%d) {FFFFFF}has {808000}escaped {FFFFFF}from his HANDCUFFS!! {808000}(Being Arrested)"tName,targetid); 
                    
SendClientMessageToAll(-1string); 
                    
GameTextForPlayer(targetid"~g~ESCAPED ~W~FROM ~R~ARRESTED!!"50005); 
                } 
                case 
36..100
                { 
                    if(
ArrestReward GetPlayerCash(playerid)) 
                    
GetPlayerName(targetidtNamesizeof(tName)); 
                    
GetPlayerName(playeridpNamesizeof(pName)); 
                    
TryingArrested[targetid] = 0
                    
ResetPlayerWeapons(targetid); 
                     
                    
format(stringsizeof(string), "{808000}%s(%d) {ffffff}has been {808000}ARRESTED {ffffff}by {00FFFF}S.W.A.T %s(%d){ffffff}!! Wanted Level: {00FFFF}%d."tName,targetidpName,playerid,GetPlayerWantedLevel(targetid)); 
                    
SendClientMessageToAll(yellowstring); 
                       
                    
format(stringsizeof(string), "~y~ARRESTED BY %s(%d)~n~~W~YOU LOST ~R~$%d"pNameplayerid, -ArrestReward); 
                    
GameTextForPlayer(targetidstring40005); 
                     
                    
format(stringsizeof(string), "~g~ARRESTED ~y~%s(%d)~n~~W~YOU GOT ~R~$%d"tNametargetidArrestReward); 
                    
GameTextForPlayer(playeridstring40005); 
                     
                    
format(stringsizeof(string), "{808000}%s(%d) {ffffff}has {ff0000}failed {ffffff}to escaped from his Handcuffs!! {808000}(Being Arrested)"tName,targetid); 
                    
SendClientMessageToAll(yellowstring); 
                     
                    
GivePlayerMoney(targetid, -ArrestReward); 
                    
GivePlayerMoney(playeridArrestReward); 
                } 
            } 
        } 
        else 
SendClientMessage(playerid, -1"{FF0000}Error: {FFFFFF}You can use this command only while being cuffed or arrested."); 
    } 
    return 
1

Error:
PHP код:
error 017undefined symbol "IsPlayerNearPlayer"
if (targetid == INVALID_PLAYER_ID || !IsPlayerNearPlayer(playeridtargetid6.0)) 
Quote:
Originally Posted by JasonRiggs
Посмотреть сообщение
No because it's nothing from the command itself, You should do something like.. An array defined globally that stores the ID of the player getting arrested, so you can use this array instead of "targetid".. Example:

You can create either an array or an enum..

PHP код:
enum pinfo
{
     
pArresting
}
new 
PlayerInfo[MAX_PLAYERS][pinfo]; 
or an array..

PHP код:
new ArrestingPlayer[MAX_PLAYERS]; 
PHP код:
cmd:arrest(playeridparams[])
{
      new 
targetid;
      if(
sscanf(params"u"targetid)) return SendClientMessage(playeridCOLOR_RED"/arrest [target]");
      
ArrestingPlayer[playerid] = targetid;

or
PHP код:
cmd:arrest(playeridparams[])
{
      new 
targetid;
      if(
sscanf(params"u"targetid)) return SendClientMessage(playeridCOLOR_RED"/arrest [target]");
      
PlayerInfo[playerid][pArresting] = targetid;

and instead of using "targetid" in the "/bc" command, use the enum or the array..
I already creating a command for it..

PHP код:
CMD:ar(playeridparams[])
{
    if(!
PoliceTeam(GetPlayerSkin(playerid)) && !SWAT(GetPlayerSkin(playerid)) && !Army(GetPlayerSkin(playerid)) && !FBII(GetPlayerSkin(playerid)) && !CIA(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)
            {
                
SecdonsToJail[targetid] = SetTimerEx("JailPlayer",5000,0,"i",targetid);
                
TryingArrested[targetid] = 1;
                
format(stringsizeof(string), "{0080FF}[BEING ARRESTED]: {FFFFFF}S.W.A.T %s(%d) has put {ADFF2F}Handcuffs {FFFFFF}on you."pNameplayerid);
                
SendClientMessage(targetidredstring);
                
ShowDescriptionText(targetidstring);
                
SetPlayerAttachedObject(targetid9194186, -0.0110000.028000, -0.022000, -15.600012, -33.699977, -81.7000350.8919991.0000001.168000);
                
SetPlayerSpecialAction(targetidSPECIAL_ACTION_CUFFED);
                
format(stringsizeof(string), "~W~AN ~B~F.B.I %s(%d) ~W~HAS CUFFED YOU!!~n~~b~PRESS [/BC] TO ESCAPE FROM THE ~Y~ARREST"pNameplayerid);
                
GameTextForPlayer(targetidstring40005);
                
format(stringsizeof(string), "{33B5FF}[BEGIN ARRESTED!!!] S.W.A.T %s(%d) trying to arrest you!! {33B5FF}Use /BC for escape from this arrested!!"pNameplayerid);
                
SendClientMessage(targetidredstring);
                
ShowDescriptionText(playeridstring);
                
                
format(stringsizeof(string), "{ffffff}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(playeridredstring);
                
ShowDescriptionText(playeridstring);
                
SetPVarInt(playerid,"ArTime",GetTickCount()+5000);
                }
                }
                return 
1;

Reply
#9

You should know how to fix that error. Either remove it, or add this

PHP код:
IsPlayerNearPlayer(playeridtargetidFloat:radius)
{
    static
        
Float:fX,
        
Float:fY,
        
Float:fZ;
    
GetPlayerPos(targetidfXfYfZ);
    return (
GetPlayerInterior(playerid) == GetPlayerInterior(targetid) && GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(targetid)) && IsPlayerInRangeOfPoint(playeridradiusfXfYfZ);

Quote:
Originally Posted by JasonRiggs
Посмотреть сообщение
No because it's nothing from the command itself, You should do something like.. An array defined globally that stores the ID of the player getting arrested, so you can use this array instead of "targetid".. Example:

You can create either an array or an enum..

PHP код:
enum pinfo
{
     
pArresting
}
new 
PlayerInfo[MAX_PLAYERS][pinfo]; 
or an array..

PHP код:
new ArrestingPlayer[MAX_PLAYERS]; 
PHP код:
cmd:arrest(playeridparams[])
{
      new 
targetid;
      if(
sscanf(params"u"targetid)) return SendClientMessage(playeridCOLOR_RED"/arrest [target]");
      
ArrestingPlayer[playerid] = targetid;

or
PHP код:
cmd:arrest(playeridparams[])
{
      new 
targetid;
      if(
sscanf(params"u"targetid)) return SendClientMessage(playeridCOLOR_RED"/arrest [target]");
      
PlayerInfo[playerid][pArresting] = targetid;

and instead of using "targetid" in the "/bc" command, use the enum or the array..
I understand where you're coming from, but you can just make a parameter in the command itself to get the input from the user on who is arresting them.
Reply
#10

I've trying your code and it's not worked! It's saying again Example: rocking(0) has been arrested by S.W.A.T rocking(0) why? and you are not understand what i mean.. I just want fix this text... I want Example: Rocking(0) has been arrested by S.W.A.T Jackons[1] u understand?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)