RoadBlock not create
#1

Hello, i compile my gm and all ist fine, but in game when type /roadblock 1 not create, it's show me again and again "/roadblock [1-20]"
PHP код:
CMD:roadblock(playerid,params[])
    {
        if(
IsPlayerConnected(playerid))
        {
            new 
x_nr[256];
            
            if(!
IsACop(playerid)) return SendClientMessage(playeridCOLOR_GREY"You are not a cop!");
            if(
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playeridCOLOR_GREY"You can`t place a RoadBlock when you are in a vehicle!");
            if(!
strlen(x_nr))
            {
                
SCM(playerid,-1,"/roadblock [1-20]");
                return 
1;
            }
            new 
Float:XFloat:YFloat:ZFloat:A;
            
GetPlayerPos(playeridXYZ);
            
GetPlayerFacingAngle(playeridA);
            if(
strcmp(x_nr,"1",true) == 0)
            {
                 if(!
RoadBlock1[playerid])
                {
                    
RoadBlock1[playerid]=true;
                    
RB1[playerid] = CreateObject(979XYZ0.00.0A);
                }
                else return 
SendClientMessage(playeridCOLOR_GREY"Road block already created on this slot");
            }
               else if(
strcmp(x_nr,"2",true) == 0)
            {
                 if(!
RoadBlock2[playerid])
                {
                    
RoadBlock2[playerid]=true;
                    
RB2[playerid] = CreateObject(979XYZ0.00.0A);
                }
                else return 
SendClientMessage(playeridCOLOR_GREY"Road block already created on this slot");
            }
               else if(
strcmp(x_nr,"3",true) == 0)
            {
                 if(!
RoadBlock3[playerid])
                {
                    
RoadBlock3[playerid]=true;
                    
RB3[playerid] = CreateObject(979XYZ0.00.0A);
                }
                else return 
SendClientMessage(playeridCOLOR_GREY"Road block already created on this slot");
            }
               else if(
strcmp(x_nr,"4",true) == 0)
            {
                 if(!
RoadBlock4[playerid])
                {
                    
RoadBlock4[playerid]=true;
                    
RB4[playerid] = CreateObject(979XYZ0.00.0A);
                }
                else return 
SendClientMessage(playeridCOLOR_GREY"Road block already created on this slot");
            }
               else if(
strcmp(x_nr,"5",true) == 0)
            {
                 if(!
RoadBlock5[playerid])
                {
                    
RoadBlock5[playerid]=true;
                    
RB5[playerid] = CreateObject(979XYZ0.00.0A);
                }
                else return 
SendClientMessage(playeridCOLOR_GREY"Road block already created on this slot");
            }
               else if(
strcmp(x_nr,"6",true) == 0)
            {
                 if(!
RoadBlock6[playerid])
                {
                    
RoadBlock6[playerid]=true;
                    
RB6[playerid] = CreateObject(979XYZ0.00.0A);
                }
                else return 
SendClientMessage(playeridCOLOR_GREY"Road block already created on this slot");
            }
               else if(
strcmp(x_nr,"7",true) == 0)
            {
                 if(!
RoadBlock7[playerid])
                {
                    
RoadBlock7[playerid]=true;
                    
RB7[playerid] = CreateObject(979XYZ0.00.0A);
                }
                else return 
SendClientMessage(playeridCOLOR_GREY"Road block already created on this slot");
            }
               else if(
strcmp(x_nr,"8",true) == 0)
            {
                 if(!
RoadBlock8[playerid])
                {
                    
RoadBlock8[playerid]=true;
                    
RB8[playerid] = CreateObject(979XYZ0.00.0A);
                }
                else return 
SendClientMessage(playeridCOLOR_GREY"Road block already created on this slot");
            }
               else if(
strcmp(x_nr,"9",true) == 0)
            {
                 if(!
RoadBlock9[playerid])
                {
                    
RoadBlock9[playerid]=true;
                    
RB9[playerid] = CreateObject(979XYZ0.00.0A);
                }
                else return 
SendClientMessage(playeridCOLOR_GREY"Road block already created on this slot");
            }
               else if(
strcmp(x_nr,"10",true) == 0)
            {
                 if(!
RoadBlock10[playerid])
                {
                    
RoadBlock10[playerid]=true;
                    
RB10[playerid] = CreateObject(979XYZ0.00.0A);
                }
                else return 
SendClientMessage(playeridCOLOR_GREY"Road block already created on this slot");
            }
               else if(
strcmp(x_nr,"11",true) == 0)
            {
                 if(!
RoadBlock11[playerid])
                {
                    
RoadBlock11[playerid]=true;
                    
RB11[playerid] = CreateObject(979XYZ0.00.0A);
                }
                else return 
SendClientMessage(playeridCOLOR_GREY"Road block already created on this slot");
            }
               else if(
strcmp(x_nr,"12",true) == 0)
            {
                 if(!
RoadBlock12[playerid])
                {
                    
RoadBlock12[playerid]=true;
                    
RB12[playerid] = CreateObject(979XYZ0.00.0A);
                }
                else return 
SendClientMessage(playeridCOLOR_GREY"Road block already created on this slot");
            }
               else if(
strcmp(x_nr,"13",true) == 0)
            {
                 if(!
RoadBlock13[playerid])
                {
                    
RoadBlock13[playerid]=true;
                    
RB13[playerid] = CreateObject(979XYZ0.00.0A);
                }
                else return 
SendClientMessage(playeridCOLOR_GREY"Road block already created on this slot");
            }
               else if(
strcmp(x_nr,"14",true) == 0)
            {
                 if(!
RoadBlock14[playerid])
                {
                    
RoadBlock14[playerid]=true;
                    
RB14[playerid] = CreateObject(979XYZ0.00.0A);
                }
                else return 
SendClientMessage(playeridCOLOR_GREY"Road block already created on this slot");
            }
               else if(
strcmp(x_nr,"15",true) == 0)
            {
                 if(!
RoadBlock15[playerid])
                {
                    
RoadBlock15[playerid]=true;
                    
RB15[playerid] = CreateObject(979XYZ0.00.0A);
                }
                else return 
SendClientMessage(playeridCOLOR_GREY"Road block already created on this slot");
            }
               else if(
strcmp(x_nr,"16",true) == 0)
            {
                 if(!
RoadBlock16[playerid])
                {
                    
RoadBlock16[playerid]=true;
                    
RB16[playerid] = CreateObject(979XYZ0.00.0A);
                }
                else return 
SendClientMessage(playeridCOLOR_GREY"Road block already created on this slot");
            }
               else if(
strcmp(x_nr,"17",true) == 0)
            {
                 if(!
RoadBlock17[playerid])
                {
                    
RoadBlock17[playerid]=true;
                    
RB17[playerid] = CreateObject(979XYZ0.00.0A);
                }
                else return 
SendClientMessage(playeridCOLOR_GREY"Road block already created on this slot");
            }
               else if(
strcmp(x_nr,"18",true) == 0)
            {
                 if(!
RoadBlock18[playerid])
                {
                    
RoadBlock18[playerid]=true;
                    
RB18[playerid] = CreateObject(979XYZ0.00.0A);
                }
                else return 
SendClientMessage(playeridCOLOR_GREY"Road block already created on this slot");
            }
               else if(
strcmp(x_nr,"19",true) == 0)
            {
                 if(!
RoadBlock19[playerid])
                {
                    
RoadBlock19[playerid]=true;
                    
RB19[playerid] = CreateObject(979XYZ0.00.0A);
                }
                else return 
SendClientMessage(playeridCOLOR_GREY"Road block already created on this slot");
            }
               else if(
strcmp(x_nr,"20",true) == 0)
            {
                 if(!
RoadBlock20[playerid])
                {
                    
RoadBlock20[playerid]=true;
                    
RB20[playerid] = CreateObject(979XYZ0.00.0A);
                }
                else return 
SendClientMessage(playeridCOLOR_GREY"Road block already created on this slot");
            }
            else
            {
                
SendClientMessage(playeridCOLOR_GREY"* Invalid roadblock number !");
                return 
1;
            }
            
SetPlayerPos(playeridXYZ+2);
            
GameTextForPlayer(playerid"~w~Roadblock ~r~Placed"50005);
        }
        return 
1;
    } 
Reply
#2

Your x_nr is empty, you don't copy there anything from params. Also please do not ever use variable names such as RB1, RB2, RB3, that's what arrays are for! (and your code would be 20 times shorter)
Reply
#3

He's not kidding.

pawn Код:
// At the top of your script:
#define MAX_ROADBLOCKS  20
new RoadBlock[MAX_PLAYERS][MAX_ROADBLOCKS];

// Command
CMD:roadblock(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        if(!IsACop(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not a cop!");
        if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You can`t place a Roadblock when you are in a vehicle!");
        for(new i = 0; i < MAX_ROADBLOCKS; i++)
        {
            if(IsValidObject(RoadBlock[playerid][i])) continue;
            new Float:X, Float:Y, Float:Z, Float:A;
            GetPlayerPos(playerid, X, Y, Z);
            GetPlayerFacingAngle(playerid, A);
            RoadBlock[playerid][i] = CreateObject(979, X + (2.0 * floatsin(-A, degrees)), Y + (2.0 * floatcos(-A, degrees)), Z, 0.0, 0.0, A);
            GameTextForPlayer(playerid, "~w~Roadblock ~r~Placed", 5000, 5);
            return 1;
        }
        SendClientMessage(playerid, COLOR_GREY, "Roadblock limit reached. Please remove some Roadblocks first!");
    }
    return 1;
}
Although, if you use this, you'll need to alter any commands related to roadblocks. Especially your roadblock removal command.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)