STRCMP > ZCMD (again-.-) [+Rep]
#1

Hey guys, i'm really sorry but i'm new to ZCMD.. I'm trying to Convert [NYRP]Mike.'s script, but i have failed lol..
Can somebody convert it for me? So that i can see the difference?

PHP код:
if(strcmp(cmd"/crb"true) == 0)
        {
            if(
IsPlayerConnected(playerid) && IsACop(playerid) || IsPlayerAdmin(playerid))
        {
                        
tmp strtok(cmdtextidx);
                        if(!
strlen(tmp))
                        {
                                
SendClientMessage(playeridCOLOR_WHITE"USAGE: /crb [Roadblock ID]");
                                
SendClientMessage(playeridCOLOR_LIGHTBLUE"Available Roadblocks:");
                                
SendClientMessage(playeridCOLOR_GRAD1"| 1: Small Roadblock");
                                
SendClientMessage(playeridCOLOR_GRAD1"| 2: Medium Roadblock");
                                
SendClientMessage(playeridCOLOR_GRAD1"| 3: Big Roadblock");
                                
SendClientMessage(playeridCOLOR_GRAD1"| 3: Cone");
                                return 
1;
                        }
            new 
rb strval(tmp);
            if (
rb == 1)
                        {
                                
PlayerPlaySound(playerid10520.00.00.0);
                                new 
Float:plocx,Float:plocy,Float:plocz,Float:ploca;
                        
GetPlayerPos(playeridplocxplocyplocz);
                        
GetPlayerFacingAngle(playerid,ploca);
                        
CreateRoadblock(1459,plocx,plocy,plocz,ploca);
                        
format(string,sizeof(string),"[HQ]: Officer %s has placed a Roadblock(1) at his position, over.",GPN(playerid));
                        
SendRadioMessage(1,COLOR_BLUE,string);
                        
GameTextForPlayer(playerid,"~w~Roadblock ~b~Placed!",3000,1);
                                return 
1;
                        }
                        else if (
rb == 2)
                        {
                                
PlayerPlaySound(playerid10520.00.00.0);
                                new 
Float:plocx,Float:plocy,Float:plocz,Float:ploca;
                        
GetPlayerPos(playeridplocxplocyplocz);
                        
GetPlayerFacingAngle(playerid,ploca);
                        
CreateRoadblock(978,plocx,plocy,plocz+0.6,ploca);
                        
format(string,sizeof(string),"[HQ]: Officer %s has placed a Roadblock(2) at his position, over.",GPN(playerid));
                        
SendRadioMessage(1,COLOR_BLUE,string);
                        
GameTextForPlayer(playerid,"~w~Roadblock ~b~Placed!",3000,1);
                                return 
1;
                        }
                        else if (
rb == 3)
                        {
                                
PlayerPlaySound(playerid10520.00.00.0);
                                new 
Float:plocx,Float:plocy,Float:plocz,Float:ploca;
                        
GetPlayerPos(playeridplocxplocyplocz);
                        
GetPlayerFacingAngle(playerid,ploca);
                        
CreateRoadblock(981,plocx,plocy,plocz+0.9,ploca+180);
                        
format(string,sizeof(string),"[HQ]: Officer %s has placed a Roadblock(3) at his position, over.",GPN(playerid));
                        
SendRadioMessage(1,COLOR_BLUE,string);
                        
GameTextForPlayer(playerid,"~w~Roadblock ~g~Placed!",3000,1);
                        
SetPlayerPos(playeridplocxplocy+1.3plocz);
                                return 
1;
                        }
                        else if (
rb == 4)
                        {
                                
PlayerPlaySound(playerid10520.00.00.0);
                                new 
Float:plocx,Float:plocy,Float:plocz,Float:ploca;
                        
GetPlayerPos(playeridplocxplocyplocz);
                        
GetPlayerFacingAngle(playerid,ploca);
                        
CreateRoadblock(1238,plocx,plocy,plocz+0.2,ploca);
                        
format(string,sizeof(string),"[HQ]: Officer %s has placed a Traffic Cone(1) at his position, over.",GPN(playerid));
                        
SendRadioMessage(1,COLOR_BLUE,string);
                        
GameTextForPlayer(playerid,"~w~Cone ~g~Placed!",3000,1);
                                return 
1;
                        }
                        
/*else if (rb == 4)
                        {
                                PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                                new Float:plocx,Float:plocy,Float:plocz,Float:ploca;
                        GetPlayerPos(playerid, plocx, plocy, plocz);
                        GetPlayerFacingAngle(playerid,ploca);
                        CreateRoadblock(1425,plocx,plocy,plocz+0.6,ploca);
                        format(string,sizeof(string),"[HQ]: Officer %s has placed a Detour Sign(4) at his position, over.",GPN(playerid));
                        SendRadioMessage(1,COLOR_BLUE,string);
                        GameTextForPlayer(playerid,"~w~Sign ~g~Placed!",3000,1);
                                return 1;
                        }
                        else if (rb == 5)
                        {
                                PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                                new Float:plocx,Float:plocy,Float:plocz,Float:ploca;
                        GetPlayerPos(playerid, plocx, plocy, plocz);
                        GetPlayerFacingAngle(playerid,ploca);
                        CreateRoadblock(3265,plocx,plocy,plocz-0.5,ploca);
                        format(string,sizeof(string),"[HQ]: Officer %s has placed a Will Be Sign(5) at his position, over.",GPN(playerid));
                        SendRadioMessage(1,COLOR_BLUE,string);
                        GameTextForPlayer(playerid,"~w~Sign ~g~Placed!",3000,1);
                                return 1;
                        }
                        else if (rb == 6)
                        {
                                PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                                new Float:plocx,Float:plocy,Float:plocz,Float:ploca;
                        GetPlayerPos(playerid, plocx, plocy, plocz);
                        GetPlayerFacingAngle(playerid,ploca);
                        CreateRoadblock(3091,plocx,plocy,plocz+0.5,ploca+180);
                        format(string,sizeof(string),"[HQ]: Officer %s has placed a Line Closed Sign(6) at his position, over.",GPN(playerid));
                        SendRadioMessage(1,COLOR_BLUE,string);
                        GameTextForPlayer(playerid,"~w~Sign ~g~Placed!",3000,1);
                                return 1;
                        }*/
                
}
            return 
1;
        }
        else if (
strcmp(cmd,"/rrb",true) == 0)
        {
            if(
IsPlayerConnected(playerid) && IsACop(playerid) || IsPlayerAdmin(playerid))
        {
                
DeleteClosestRoadblock(playerid);
                
format(string,sizeof(string),"[HQ]: Officer %s has removed a Roadblock, over.",GPN(playerid));
                
SendRadioMessage(1,COLOR_BLUE,string);
                
GameTextForPlayer(playerid,"~w~Roadblock ~r~Removed!",3000,1);
                }
            return 
1;
        }
        else if (
strcmp(cmd,"/rrball",true) == 0)
        {
            if(
IsPlayerConnected(playerid) && IsACop(playerid) || IsPlayerAdmin(playerid))
        {
                        if(
PlayerInfo[playerid][pRank] >= || IsPlayerAdmin(playerid)) // This being the default Chief rank in LA-RP change if neccesary.
                        
{
                        
DeleteAllRoadblocks(playerid);
                        
format(string,sizeof(string),"[HQ]: Officer %s has removed all Roadblocks in the area, over.",GPN(playerid));
                        
SendRadioMessage(1,COLOR_BLUE,string);
                        
GameTextForPlayer(playerid,"~b~All ~w~Roadblocks ~r~Removed!",3000,1);
                        }
                }
            return 
1;
        } 
Thanks
Reply
#2

Compare the following two boxes and you'll understand how to convert every command:

pawn Код:
if(strcmp(cmd, "/crb", true) == 0)
{
   /* Content of command. */
}
pawn Код:
COMMAND:crb(playerid, params[])
{
   /* Content of command. */
}
Take a look at: https://sampforum.blast.hk/showthread.php?tid=91354
Reply
#3

Here you go

pawn Код:
CMD:crb(playerid, params[])
{
    if(IsPlayerConnected(playerid) && IsACop(playerid) || IsPlayerAdmin(playerid))
    {
        new rb;
        if(sscanf(params, "d", rb))
        {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /crb [Roadblock ID]");
            SendClientMessage(playerid, COLOR_LIGHTBLUE, "Available Roadblocks:");
            SendClientMessage(playerid, COLOR_GRAD1, "| 1: Small Roadblock");
            SendClientMessage(playerid, COLOR_GRAD1, "| 2: Medium Roadblock");
            SendClientMessage(playerid, COLOR_GRAD1, "| 3: Big Roadblock");
            SendClientMessage(playerid, COLOR_GRAD1, "| 3: Cone");
            return 1;
        }
        if (rb == 1)
        {
            PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
            new Float:plocx,Float:plocy,Float:plocz,Float:ploca;
            GetPlayerPos(playerid, plocx, plocy, plocz);
            GetPlayerFacingAngle(playerid,ploca);
            CreateRoadblock(1459,plocx,plocy,plocz,ploca);
            format(string,sizeof(string),"[HQ]: Officer %s has placed a Roadblock(1) at his position, over.",GPN(playerid));
            SendRadioMessage(1,COLOR_BLUE,string);
            GameTextForPlayer(playerid,"~w~Roadblock ~b~Placed!",3000,1);
            return 1;
        }
        else if (rb == 2)
        {
            PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
            new Float:plocx,Float:plocy,Float:plocz,Float:ploca;
            GetPlayerPos(playerid, plocx, plocy, plocz);
            GetPlayerFacingAngle(playerid,ploca);
            CreateRoadblock(978,plocx,plocy,plocz+0.6,ploca);
            format(string,sizeof(string),"[HQ]: Officer %s has placed a Roadblock(2) at his position, over.",GPN(playerid));
            SendRadioMessage(1,COLOR_BLUE,string);
            GameTextForPlayer(playerid,"~w~Roadblock ~b~Placed!",3000,1);
            return 1;
        }
        else if (rb == 3)
        {
            PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
            new Float:plocx,Float:plocy,Float:plocz,Float:ploca;
            GetPlayerPos(playerid, plocx, plocy, plocz);
            GetPlayerFacingAngle(playerid,ploca);
            CreateRoadblock(981,plocx,plocy,plocz+0.9,ploca+180);
            format(string,sizeof(string),"[HQ]: Officer %s has placed a Roadblock(3) at his position, over.",GPN(playerid));
            SendRadioMessage(1,COLOR_BLUE,string);
            GameTextForPlayer(playerid,"~w~Roadblock ~g~Placed!",3000,1);
            SetPlayerPos(playerid, plocx, plocy+1.3, plocz);
            return 1;
        }
        else if (rb == 4)
        {
            PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
            new Float:plocx,Float:plocy,Float:plocz,Float:ploca;
            GetPlayerPos(playerid, plocx, plocy, plocz);
            GetPlayerFacingAngle(playerid,ploca);
            CreateRoadblock(1238,plocx,plocy,plocz+0.2,ploca);
            format(string,sizeof(string),"[HQ]: Officer %s has placed a Traffic Cone(1) at his position, over.",GPN(playerid));
            SendRadioMessage(1,COLOR_BLUE,string);
            GameTextForPlayer(playerid,"~w~Cone ~g~Placed!",3000,1);
            return 1;
        }
                        /*else if (rb == 4)
                        {
                                PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                                new Float:plocx,Float:plocy,Float:plocz,Float:ploca;
                        GetPlayerPos(playerid, plocx, plocy, plocz);
                        GetPlayerFacingAngle(playerid,ploca);
                        CreateRoadblock(1425,plocx,plocy,plocz+0.6,ploca);
                        format(string,sizeof(string),"[HQ]: Officer %s has placed a Detour Sign(4) at his position, over.",GPN(playerid));
                        SendRadioMessage(1,COLOR_BLUE,string);
                        GameTextForPlayer(playerid,"~w~Sign ~g~Placed!",3000,1);
                                return 1;
                        }
                        else if (rb == 5)
                        {
                                PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                                new Float:plocx,Float:plocy,Float:plocz,Float:ploca;
                        GetPlayerPos(playerid, plocx, plocy, plocz);
                        GetPlayerFacingAngle(playerid,ploca);
                        CreateRoadblock(3265,plocx,plocy,plocz-0.5,ploca);
                        format(string,sizeof(string),"[HQ]: Officer %s has placed a Will Be Sign(5) at his position, over.",GPN(playerid));
                        SendRadioMessage(1,COLOR_BLUE,string);
                        GameTextForPlayer(playerid,"~w~Sign ~g~Placed!",3000,1);
                                return 1;
                        }
                        else if (rb == 6)
                        {
                                PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                                new Float:plocx,Float:plocy,Float:plocz,Float:ploca;
                        GetPlayerPos(playerid, plocx, plocy, plocz);
                        GetPlayerFacingAngle(playerid,ploca);
                        CreateRoadblock(3091,plocx,plocy,plocz+0.5,ploca+180);
                        format(string,sizeof(string),"[HQ]: Officer %s has placed a Line Closed Sign(6) at his position, over.",GPN(playerid));
                        SendRadioMessage(1,COLOR_BLUE,string);
                        GameTextForPlayer(playerid,"~w~Sign ~g~Placed!",3000,1);
                                return 1;
                        }*/

    }
    return 1;
}

CMD:rrb(playerid, params[])
{
    if(IsPlayerConnected(playerid) && IsACop(playerid) || IsPlayerAdmin(playerid))
    {
        DeleteClosestRoadblock(playerid);
        format(string,sizeof(string),"[HQ]: Officer %s has removed a Roadblock, over.",GPN(playerid));
        SendRadioMessage(1,COLOR_BLUE,string);
        GameTextForPlayer(playerid,"~w~Roadblock ~r~Removed!",3000,1);
    }
    return 1;
}

CMD:rrball(playerid, params[])
{
    if(IsPlayerConnected(playerid) && IsACop(playerid) || IsPlayerAdmin(playerid))
    {
        if(PlayerInfo[playerid][pRank] >= 6 || IsPlayerAdmin(playerid)) // This being the default Chief rank in LA-RP change if neccesary.
        {
            DeleteAllRoadblocks(playerid);
            format(string,sizeof(string),"[HQ]: Officer %s has removed all Roadblocks in the area, over.",GPN(playerid));
            SendRadioMessage(1,COLOR_BLUE,string);
            GameTextForPlayer(playerid,"~b~All ~w~Roadblocks ~r~Removed!",3000,1);
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)