Array must be indexed - for variable
#2

PHP код:
CMD:bomb(playeridparams[])
{
    new
        
idx;
    if(
isnull(params))
    {
        
SendClientMessage(playeridCOLOR_GREY"USAGE: /bomb [Parameter]");
        
SendClientMessage(playeridCOLOR_GREY"Available parameters: {E6E6E6}put{AFAFAF}, {E6E6E6}activate{AFAFAF}");
        if(
PlayerData[playerid][pSwatMember])
        {
            
SendClientMessage(playeridCOLOR_FACTIONCHAT"[SWAT]: {E6E6E6}check{AFAFAF}, {E6E6E6}disarm{AFAFAF}");
        }
        return 
1;
    }
    if(!
strcmp(params"put"true4))
    {
        new
            
BombTimerID GetPVarInt(playerid"PuttingBomb"),
            
szSetting[20],
            
iTimer
                
;
                if(
sscanf(params,"ssi[20]""put",szSettingiTimer) return  SendErrorMessage(playerid"USAGE:/bomb [put] [setting] [timer]");
        if(
BombTimerID)
        {
            
KillTimer(BombTimerID);
            
DeletePVar(playerid"PuttingBomb");
            
GameTextForPlayer(playerid"~r~Stopped arming bomb"20003);
            
TogglePlayerControllable(playerid1);
            return 
1;
        }
        if (!
Inventory_HasItem(playerid"Bomb"))
            return 
SendErrorMessage(playerid"You dont have a Bomb. Visit the blackmaret and buy one or contact an illegal member.");
        if(
isnull(params))
        {
            
SendClientMessage(playeridCOLOR_GREY"USAGE: /bomb put [{E6E6E6}Vehicle ID{AFAFAF}] [{E6E6E6}Setting{AFAFAF}] [{E6E6E6}Timer (Seconds){AFAFAF}]");
            
SendClientMessage(playeridCOLOR_WHITE"Available settings: {E6E6E6}Ignition, timer, speed, remote"),
            
SendClientMessage(playeridCOLOR_GREY"NOTE: Use \"{E6E6E6}/bomb put help{AFAFAF}\" for explinations of use.");
            return 
1;
        }
        if(!
strcmp(szParameters[1], "help"true5))
        {
            
SendClientMessage(playeridCOLOR_WHITE"[ BOMB PUT MANUAL ]");
            
SendClientMessage(playeridCOLOR_WHITE"Setting 1: IGNITION {AAAAAA}- Activates the bomb timer after the {E6E6E6}vehicle's ignition{AAAAAA} is activated.");
            
SendClientMessage(playeridCOLOR_WHITE"Setting 2: TIMER {AAAAAA}- {E6E6E6}Immediately{AAAAAA} activates the bomb timer.");
            
SendClientMessage(playeridCOLOR_WHITE"Setting 3: SPEED {AAAAAA}- The bomb will explode as soon as the {E6E6E6}vehicle speed{AAAAAA}");
            
SendClientMessage(playeridCOLOR_WHITE"drops under {E6E6E6}40{AAAAAA} km/h. It is activated {E6E6E6}as soon as the vehicle is started{AAAAAA}.");
            
SendClientMessage(playeridCOLOR_WHITE"Setting 4: REMOTE {AAAAAA}- Bomb is activated with \"{E6E6E6}/bomb activate{AAAAAA}\". Note that the {E6E6E6}remote range is limited{AAAAAA}.");
            
SendClientMessage(playeridCOLOR_WHITE"The timer: {AAAAAA}- Decides how long it takes for the bomb to {E6E6E6}detonate{AAAAAA} from the moment it is activated.");
            
SendClientMessage(playeridCOLOR_WHITE"You can get the {E6E6E6}ID{AAAAAA} of the vehicle by using the \"{E6E6E6}/dl{AAAAAA}\" command.");
            
SendClientMessage(playeridCOLOR_WHITE"[ END OF BOMB PUT MANUAL ]");
            return 
1;
        }
        if( !
GetVehicleModelstrvalszParameters[1] ) ) ) // The car isn't spawned
        
{
            
SendClientMessage(playeridCOLOR_GREY"ERROR: Invalid vehicle ID.");
            
SendClientMessage(playeridCOLOR_GREY"TIP: You can use \"{E6E6E6}/dl{AFAFAF}\" to see the IDs of nearby vehicles.");
            return 
1;
        }
        if(
IsPlayerInAnyVehicle(playerid))
        {
            
SendClientMessage(playeridCOLOR_GREY"ERROR: You need to stand close to the vehicle, not in it.");
            return 
1;
        }
        new
                    
iVehicleID strval(szParameters[1]),
            
Float:     f_Pos[3];
        
GetVehiclePos(iVehicleIDf_Pos[0], f_Pos[1], f_Pos[2]);
        if(!
IsPlayerInRangeOfPoint(playeridBOMB_USE_DISTANCEf_Pos[0], f_Pos[1], f_Pos[2]))
        {
            
SendClientMessage(playeridCOLOR_GREY"ERROR: You are not close enough to this vehicle.");
            return 
1;
        }
        new
            
iSetting;
        if(!
strcmp(szSetting"ignition"true9))
        {
            if(
iTimer || iTimer 60)
            {
                
SendClientMessage(playeridCOLOR_GREY"ERROR: Invalid timer input. Must be between {E6E6E6}1{AFAFAF} and {E6E6E6}60{AFAFAF} seconds.");
                return 
1;
            }
            
iSetting VEHICLE_BOMB_TYPE_IGNITION;
            
Inventory_Remove(playerid"Bomb");
        }
        else if(!
strcmp(szSetting"timer"true6))
        {
            if(
iTimer 10 || iTimer 120)
            {
                
SendClientMessage(playeridCOLOR_GREY"ERROR: Invalid timer input. Must be between {E6E6E6}10{AFAFAF} and {E6E6E6}120{AFAFAF} seconds.");
                return 
1;
            }
            
iSetting VEHICLE_BOMB_TYPE_TIMER;
            
Inventory_Remove(playerid"Bomb");
        }
        else if(!
strcmp(szSetting"speed"true6))
        {
            if(
iTimer 15 || iTimer 60)
            {
                
SendClientMessage(playeridCOLOR_GREY"ERROR: Invalid timer input. Must be between {E6E6E6}15{AFAFAF} and {E6E6E6}60{AFAFAF} seconds.");
                return 
1;
            }
            
iSetting VEHICLE_BOMB_TYPE_SPEED;
            
Inventory_Remove(playerid"Bomb");
        }
        else if(!
strcmp(szSetting"remote"true6))
        {
            if(
iTimer || iTimer 60)
            {
                
SendClientMessage(playeridCOLOR_GREY"ERROR: Invalid timer input. Must be between {E6E6E6}1{AFAFAF} and {E6E6E6}60{AFAFAF} seconds.");
                return 
1;
            }
            
iSetting VEHICLE_BOMB_TYPE_REMOTE;
            
Inventory_Remove(playerid"Bomb");
        }
        else
        {
            
SendClientMessage(playeridCOLOR_GREY"ERROR: Invalid setting. Please refer to manual: \"{E6E6E6}/bomb put help{AFAFAF}\".");
            return 
1;
        }
        
ResetBombInfo(iVehicleID);
        
ApplyAnimation(playerid"BOMBER""BOM_Plant_Loop"2.00000BOMB_ARMTIME 11000);
        
SetPVarInt(playerid"PuttingBomb"SetTimerEx("PlayerPutBombInVehicle"00"ddddd"BOMB_ARMTIMEplayeridiVehicleIDiSettingiTimer));
        return 
1;
    }
    if(!
strcmp(szParameters[0], "activate"true4))
    {
        new
            
Float:     f_vPos[3],
                    
iHasAnyRemoteBombs;
        for(new 
iMAX_VEHICLESi++)
        {
            if(
g_Bomb_Vehicles[i][bv_i_ArmedType] == VEHICLE_BOMB_TYPE_REMOTE && g_Bomb_Vehicles[i][bv_i_BombOwner] == playerid)
            {
                
iHasAnyRemoteBombs 1;
                
GetVehiclePos(if_vPos[0], f_vPos[1], f_vPos[2]);
                if(
IsPlayerInRangeOfPoint(playerid100.0f_vPos[0], f_vPos[1], f_vPos[2]))
                {
                    
g_Bomb_Vehicles[i][bv_i_BombOwner] = INVALID_PLAYER_ID;
                    
BombActivated(i);
                }
            }
        }
        if(!
iHasAnyRemoteBombs)
        {
            
SendClientMessage(playeridCOLOR_GREY"ERROR: You haven't planted any bombs.");
            return 
1;
        }
        new
            
Float:    f_Pos[3];
        
GetPlayerPos(playeridf_Pos[0], f_Pos[1], f_Pos[2]);
        
PlayerPlaySound(playerid6400f_Pos[0], f_Pos[1], f_Pos[2]);
        
SendClientMessage(playeridCOLOR_ORANGE"You pressed the trigger on your remote to active your bomb(s).");
        
SendClientMessage(playeridCOLOR_GREY"NOTE: The distance for the remote is limited.");
        return 
1;
    }
    if(
PlayerData[playerid][pSwatMember])
    {
        if(!
strcmp(szParameters[0], "check"true4))
        {
            new
                
BombCheckingTimerID GetPVarInt(playerid"CheckingForBombs");
            if(
BombCheckingTimerID)
            {
                
KillTimer(BombCheckingTimerID);
                
DeletePVar(playerid"CheckingForBombs");
                
GameTextForPlayer(playerid"~r~Stopped looking for bombs"20003);
                return 
1;
            }
            if(
GetPVarInt(playerid"DisarmingBomb"))
            {
                
SendClientMessage(playeridCOLOR_GREY"You are busy disarming the bomb.");
                return 
1;
            }
            if(
isnull(szParameters[1]))
            {
                
SendClientMessage(playeridCOLOR_GREY"USAGE: /bomb check [Vehicle ID]");
                return 
1;
            }
            new
                
iVehicleID strval(szParameters[1]);
            if(!
GetVehicleModel(iVehicleID))
            {
                
SendClientMessage(playeridCOLOR_GREY"ERROR: Invalid vehicle ID.");
                
SendClientMessage(playeridCOLOR_GREY"TIP: You can use \"{E6E6E6}/dl{AFAFAF}\" to see the IDs of nearby vehicles.");
                return 
1;
            }
            if(
IsPlayerInAnyVehicle(playerid))
            {
                
SendClientMessage(playeridCOLOR_GREY"ERROR: You need to stand close to the vehicle, not in it.");
                return 
1;
            }
            new
                
Floatf_vPos[3];
            
GetVehiclePos(iVehicleIDf_vPos[0], f_vPos[1], f_vPos[2]);
            if(!
IsPlayerInRangeOfPoint(playeridBOMB_USE_DISTANCEf_vPos[0], f_vPos[1], f_vPos[2]))
            {
                
SendClientMessage(playeridCOLOR_GREY"You are not close enough to the vehicle.");
                return 
1;
            }
            
GameTextForPlayer(playerid"~g~Checking for bombs... ~n~ ~y~Type ~r~/bomb check~y~ again to stop."BOMB_CHECKTIME 11003);
            
ApplyAnimation(playerid"BOMBER""BOM_Plant_Loop"2.00000BOMB_CHECKTIME 11000);
            
SetPVarInt(playerid"CheckingForBombs"SetTimerEx("CheckForBombs"BOMB_CHECKTIME 10000"dd"playeridiVehicleID));
            return 
1;
        }
        if(!
strcmp(szParameters[0], "disarm"true4))
        {
            new
                
DisarmingBombTimerID GetPVarInt(playerid"DisarmingBomb");
            if(
DisarmingBombTimerID)
            {
                
KillTimer(DisarmingBombTimerID);
                
DeletePVar(playerid"DisarmingBomb");
                
GameTextForPlayer(playerid"~r~Stopped disarming the bomb"20003);
                return 
1;
            }
            if(
GetPVarInt(playerid"CheckingForBombs"))
            {
                
SendClientMessage(playeridCOLOR_GREY"You are busy checking for bombs.");
                return 
1;
            }
            if(
isnull(szParameters[1]))
            {
                
SendClientMessage(playeridCOLOR_GREY"USAGE: /bomb disarm [Vehicle ID]");
                
SendClientMessage(playeridCOLOR_GREY"TIP: You can use \"{E6E6E6}/dl{AFAFAF}\" to see the IDs of nearby vehicles.");
                return 
1;
            }
            new
                
iVehicleID strval(szParameters[1]);
            if(!
GetVehicleModel(iVehicleID))
            {
                
SendClientMessage(playeridCOLOR_GREY"ERROR: Invalid vehicle ID.");
                
SendClientMessage(playeridCOLOR_GREY"TIP: You can use \"{E6E6E6}/dl{AFAFAF}\" to see the IDs of nearby vehicles.");
                return 
1;
            }
            if(
IsPlayerInAnyVehicle(playerid))
            {
                
SendClientMessage(playeridCOLOR_GREY"ERROR: You need to stand close to the vehicle, not in it.");
                return 
1;
            }
            new
                
Floatf_vPos[3];
            
GetVehiclePos(iVehicleIDf_vPos[0], f_vPos[1], f_vPos[2]);
            if(!
IsPlayerInRangeOfPoint(playeridBOMB_USE_DISTANCEf_vPos[0], f_vPos[1], f_vPos[2]))
            {
                
SendClientMessage(playeridCOLOR_GREY"You are not close enough to the vehicle.");
                return 
1;
            }
            if(
GetPVarInt(playerid"CheckedCarForBombs") != iVehicleID)
            {
                
SendClientMessage(playeridCOLOR_GREY"ERROR: You haven't checked this car for bombs yet, you need to see where it is first.");
                return 
1;
            }
            if(
GetPVarInt(playerid"FoundBombInCar") != iVehicleID)
            {
                
SendClientMessage(playeridCOLOR_GREY"ERROR: You haven't found any bombs on this vehicle.");
                return 
1;
            }
            
GameTextForPlayer(playerid"~g~Disarming bomb...~n~ ~y~Type ~r~/bomb disarm~y~ again to stop."BOMB_DISARMTIME 10003);
            
ApplyAnimation(playerid"BOMBER""BOM_Plant_Loop"2.00000BOMB_DISARMTIME 11000);
            
SetPVarInt(playerid"DisarmingBomb"SetTimerEx("DisarmBomb"BOMB_DISARMTIME 10000"dd"playeridiVehicleID));
            return 
1;
        }
    }
    
SendClientMessage(playeridCOLOR_GREY"ERROR: Invalid parameter. For a full list of available parameters, type \"/bomb\".");
    return 
1;

you need sscanf -> https://sampforum.blast.hk/showthread.php?tid=570927
Reply


Messages In This Thread
Array must be indexed - for variable - by solutioon - 13.12.2016, 19:23
Re: Array must be indexed - for variable - by Yaa - 13.12.2016, 19:31
Re: Array must be indexed - for variable - by solutioon - 13.12.2016, 20:16
Re: Array must be indexed - for variable - by BiosMarcel - 13.12.2016, 20:16
Re: Array must be indexed - for variable - by Yaa - 13.12.2016, 20:19
Re: Array must be indexed - for variable - by solutioon - 13.12.2016, 20:32
Re: Array must be indexed - for variable - by Yaa - 13.12.2016, 20:39
Re: Array must be indexed - for variable - by BiosMarcel - 14.12.2016, 05:11
Re: Array must be indexed - for variable - by iLearner - 14.12.2016, 05:30

Forum Jump:


Users browsing this thread: 2 Guest(s)