some help with a faction
#1

so, i tried to create the los santos emergency services faction, but im facing some errors :

pawn Код:
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(4863) : warning 225: unreachable code
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(4865) : warning 209: function "cmd_factionhelp" should return a value
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(19035) : error 032: array index out of bounds (variable "FacInfo")
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(19036) : error 032: array index out of bounds (variable "FacInfo")
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(19037) : error 032: array index out of bounds (variable "FacInfo")
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(19038) : error 032: array index out of bounds (variable "FacInfo")
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(19039) : error 032: array index out of bounds (variable "FacInfo")
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(19040) : error 032: array index out of bounds (variable "FacInfo")
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


6 Errors.

Error lines:

pawn Код:
FacInfo[5][fCars][0] = CreateVehicle(416,1177.3848,-1308.5576,14.0202,268.9371,1,3); // EMS 1
    FacInfo[5][fCars][1] = CreateVehicle(416,1178.4545,-1338.7717,14.0225,268.6550,1,3); // EMS 2
    FacInfo[5][fCars][2] = CreateVehicle(487,1162.7025,-1311.8475,31.6774,176.2470,1,3); // EMS 3
    FacInfo[5][fCars][3] = CreateVehicle(416,1135.6943,-1338.1392,13.8761,0.3299,1,3); // EMS 4
    FacInfo[5][fCars][4] = CreateVehicle(496,1147.8757,-1314.8203,13.3917,359.8757,3,1); // EMS 5
    FacInfo[5][fCars][5] = CreateVehicle(416,1142.5662,-1338.1984,13.7726,1.7702,1,3); // EMS 6
Warning lines:

pawn Код:
if(IsAMedic(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "EMS: {FFFFFF} /heal /surgery /flashlights");
and the 4865 line is just a bracket. }


what's wrong?





btw.. maybe this helps

pawn Код:
new FacInfo[MAX_FACTIONS][facInfo];
Reply
#2

for the out of bounds error, find the FacInfo[?]; thing, and replace it with FacInfo[6]
And, for the other error, I will need the whole command, can you post it please? (CMD factionhelp)
Reply
#3

Message Removed
Reply
#4

Quote:

array index out of bounds (variable "FacInfo")

What do you need more?

pawn Код:
new A[6];
Max index is 5, not 6 - 6 is length, and first index is 0
Reply
#5

Have you defined your enum at the top of your script?

for example:

pawn Код:
enum FacInfo
{
    yourvariable,
    yourvariable,
}
Reply
#6

looks like the max index was 5, i changed it to 6 but im now getting some warnings.

pawn Код:
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(981) : warning 225: unreachable code
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(1046) : warning 225: unreachable code
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(1055) : warning 209: function "LoadFactions" should return a value
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(4885) : warning 225: unreachable code
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(4887) : warning 209: function "cmd_factionhelp" should return a value
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(19057) : warning 202: number of arguments does not match definition
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(19058) : warning 202: number of arguments does not match definition
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(19059) : warning 202: number of arguments does not match definition
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(19060) : warning 202: number of arguments does not match definition
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(19061) : warning 202: number of arguments does not match definition
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(19062) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


11 Warnings.
981 line
pawn Код:
format(file, sizeof(file), "factions/EMS.ini");
1046 line
pawn Код:
format(file, sizeof(file), "factions/EMS.ini");
1055 is a bracket, this is the full code
pawn Код:
stock LoadFactions()
{
    // SAPD
    new file[64];
    format(file, sizeof(file), "factions/SAPD.ini");
    format(FacInfo[1][fRank0], 32, "%s", dini_Get(file, "Rank0"));
    format(FacInfo[1][fRank1], 32, "%s", dini_Get(file, "Rank1"));
    format(FacInfo[1][fRank2], 32, "%s", dini_Get(file, "Rank2"));
    format(FacInfo[1][fRank3], 32, "%s", dini_Get(file, "Rank3"));
    format(FacInfo[1][fRank4], 32, "%s", dini_Get(file, "Rank4"));
    format(FacInfo[1][fRank5], 32, "%s", dini_Get(file, "Rank5"));
    format(FacInfo[1][fRank6], 32, "%s", dini_Get(file, "Rank6"));
    format(FacInfo[1][fDiv1], 8, "%s", dini_Get(file, "Div1"));
    format(FacInfo[1][fDiv2], 8, "%s", dini_Get(file, "Div2"));
    format(FacInfo[1][fDiv3], 8, "%s", dini_Get(file, "Div3"));
    format(FacInfo[1][fDiv4], 8, "%s", dini_Get(file, "Div4"));
    print("SAPD files loaded successfully.");
    // Government
    format(file, sizeof(file), "factions/GOV.ini");
    format(FacInfo[2][fRank0], 32, "%s", dini_Get(file, "Rank0"));
    format(FacInfo[2][fRank1], 32, "%s", dini_Get(file, "Rank1"));
    format(FacInfo[2][fRank2], 32, "%s", dini_Get(file, "Rank2"));
    format(FacInfo[2][fRank3], 32, "%s", dini_Get(file, "Rank3"));
    format(FacInfo[2][fRank4], 32, "%s", dini_Get(file, "Rank4"));
    format(FacInfo[2][fRank5], 32, "%s", dini_Get(file, "Rank5"));
    format(FacInfo[2][fRank6], 32, "%s", dini_Get(file, "Rank6"));
    TaxPercent = dini_Int(file, "TaxPercent");
    TaxMoney = dini_Int(file, "TaxVault");
    print("Government files loaded successfully.");
    // Hitman Agency
    format(file, sizeof(file), "factions/HA.ini");
    format(FacInfo[3][fRank0], 32, "%s", dini_Get(file, "Rank0"));
    format(FacInfo[3][fRank1], 32, "%s", dini_Get(file, "Rank1"));
    format(FacInfo[3][fRank2], 32, "%s", dini_Get(file, "Rank2"));
    format(FacInfo[3][fRank3], 32, "%s", dini_Get(file, "Rank3"));
    format(FacInfo[3][fRank4], 32, "%s", dini_Get(file, "Rank4"));
    format(FacInfo[3][fRank5], 32, "%s", dini_Get(file, "Rank5"));
    format(FacInfo[3][fRank6], 32, "%s", dini_Get(file, "Rank6"));
    print("Hitman Agency files loaded successfully.");
    // News Agency
    format(file, sizeof(file), "factions/NA.ini");
    format(FacInfo[4][fRank0], 32, "%s", dini_Get(file, "Rank0"));
    format(FacInfo[4][fRank1], 32, "%s", dini_Get(file, "Rank1"));
    format(FacInfo[4][fRank2], 32, "%s", dini_Get(file, "Rank2"));
    format(FacInfo[4][fRank3], 32, "%s", dini_Get(file, "Rank3"));
    format(FacInfo[4][fRank4], 32, "%s", dini_Get(file, "Rank4"));
    format(FacInfo[4][fRank5], 32, "%s", dini_Get(file, "Rank5"));
    format(FacInfo[4][fRank6], 32, "%s", dini_Get(file, "Rank6"));
    NewsMoney = dini_Int(file, "Vault");
    print("News Agency files loaded successfully.");
    return 1;
    // Los Santos Emergency Services
    format(file, sizeof(file), "factions/EMS.ini");
    format(FacInfo[5][fRank0], 32, "%s", dini_Get(file, "Rank0"));
    format(FacInfo[5][fRank1], 32, "%s", dini_Get(file, "Rank1"));
    format(FacInfo[5][fRank2], 32, "%s", dini_Get(file, "Rank2"));
    format(FacInfo[5][fRank3], 32, "%s", dini_Get(file, "Rank3"));
    format(FacInfo[5][fRank4], 32, "%s", dini_Get(file, "Rank4"));
    format(FacInfo[5][fRank5], 32, "%s", dini_Get(file, "Rank5"));
    format(FacInfo[5][fRank6], 32, "%s", dini_Get(file, "Rank6"));
    print("Los Santos Emergency Services files loaded successfully.");
}
4885 line
pawn Код:
if(IsAMedic(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "EMS: {FFFFFF} /heal /surgery /flashlights");
4887 is a bracket, this is the full code
pawn Код:
CMD:factionhelp(playerid, params[])
{
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(!PlayerInfo[playerid][pFac]) return SendClientMessage(playerid, COLOR_GREY, "You are not in a faction.");
    // SAPD
    if(IsACop(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "SAPD: {FFFFFF}/r /d /m /tazer /cuff /uncuff /detain /track /door /gate /locker /showbadge /frisk /createspike /removespike /removespikes");
    if(IsACop(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "SAPD: {FFFFFF}/checkload /siren /ticket /wanted /mdc /drag /su /arrest /members /quitfaction");
    if(PlayerInfo[playerid][pFacDivLeader]) SendClientMessage(playerid, COLOR_YELLOW, "SAPD DIVISION LEADER: {FFFFFF}/dinvite /duninvite");
    if(IsACop(playerid) && PlayerInfo[playerid][pFacLeader]) SendClientMessage(playerid, COLOR_YELLOW, "SAPD FACTION LEADER: {FFFFFF}/gov /invite /uninvite /setrank /adjustrankname /setdivision /adjustdivisionname");
    // Government
    if(IsAGov(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "GOV: {FFFFFF}/r /d /showbadge");
    if(IsAGov(playerid) && PlayerInfo[playerid][pFacLeader]) SendClientMessage(playerid, COLOR_YELLOW, "GOV FACTION LEADER: {FFFFFF}/settax /taxvault /taxwithdraw /gov /invite /uninvite /setrank /adjustrankname");
    // Hitman Agency
    if(IsAHitman(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "HA: {FFFFFF}/ha /contracts /profile /track /order /givehit /hitmansms");
    if(IsAHitman(playerid) && PlayerInfo[playerid][pFacLeader]) SendClientMessage(playerid, COLOR_YELLOW, "HA FACTION LEADER: {FFFFFF}/invite /uninvite /setrank /adjustrankname");
    // News Agency
    if(IsAReporter(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "NA: {FFFFFF}/na /news /live");
    if(IsAReporter(playerid) && PlayerInfo[playerid][pFacLeader]) SendClientMessage(playerid, COLOR_YELLOW, "NA FACTION LEADER: {FFFFFF}/invite /uninvite /setrank /adjustrankname /newsvault /vaultwithdraw");
    return 1;
    // Los Santos Emergency Services
    if(IsAMedic(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "EMS: {FFFFFF} /heal /surgery /flashlights");
    if(IsAMedic(playerid) && PlayerInfo[playerid][pFacLeader]) SendClientMessage(playerid, COLOR_YELLOW, "EMS FACTION LEADER: {FFFFFF}/invite /uninvite /setrank /adjustrankname");
}

19057-19062 lines

pawn Код:
FacInfo[5][fCars][0] = CreateVehicle(416,1177.3848,-1308.5576,14.0202,268.9371,1,3); // EMS 1
    FacInfo[5][fCars][1] = CreateVehicle(416,1178.4545,-1338.7717,14.0225,268.6550,1,3); // EMS 2
    FacInfo[5][fCars][2] = CreateVehicle(487,1162.7025,-1311.8475,31.6774,176.2470,1,3); // EMS 3
    FacInfo[5][fCars][3] = CreateVehicle(416,1135.6943,-1338.1392,13.8761,0.3299,1,3); // EMS 4
    FacInfo[5][fCars][4] = CreateVehicle(496,1147.8757,-1314.8203,13.3917,359.8757,3,1); // EMS 5
    FacInfo[5][fCars][5] = CreateVehicle(416,1142.5662,-1338.1984,13.7726,1.7702,1,3); // EMS 6
Reply
#7

Try This for the FactionHelp one;

pawn Код:
CMD:factionhelp(playerid, params[])
{
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(!PlayerInfo[playerid][pFac]) return SendClientMessage(playerid, COLOR_GREY, "You are not in a faction.");
    // SAPD
    if(IsACop(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "SAPD: {FFFFFF}/r /d /m /tazer /cuff /uncuff /detain /track /door /gate /locker /showbadge /frisk /createspike /removespike /removespikes");
    if(IsACop(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "SAPD: {FFFFFF}/checkload /siren /ticket /wanted /mdc /drag /su /arrest /members /quitfaction");
    if(PlayerInfo[playerid][pFacDivLeader]) SendClientMessage(playerid, COLOR_YELLOW, "SAPD DIVISION LEADER: {FFFFFF}/dinvite /duninvite");
    if(IsACop(playerid) && PlayerInfo[playerid][pFacLeader]) SendClientMessage(playerid, COLOR_YELLOW, "SAPD FACTION LEADER: {FFFFFF}/gov /invite /uninvite /setrank /adjustrankname /setdivision /adjustdivisionname");
    // Government
    if(IsAGov(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "GOV: {FFFFFF}/r /d /showbadge");
    if(IsAGov(playerid) && PlayerInfo[playerid][pFacLeader]) SendClientMessage(playerid, COLOR_YELLOW, "GOV FACTION LEADER: {FFFFFF}/settax /taxvault /taxwithdraw /gov /invite /uninvite /setrank /adjustrankname");
    // Hitman Agency
    if(IsAHitman(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "HA: {FFFFFF}/ha /contracts /profile /track /order /givehit /hitmansms");
    if(IsAHitman(playerid) && PlayerInfo[playerid][pFacLeader]) SendClientMessage(playerid, COLOR_YELLOW, "HA FACTION LEADER: {FFFFFF}/invite /uninvite /setrank /adjustrankname");
    // News Agency
    if(IsAReporter(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "NA: {FFFFFF}/na /news /live");
    if(IsAReporter(playerid) && PlayerInfo[playerid][pFacLeader]) SendClientMessage(playerid, COLOR_YELLOW, "NA FACTION LEADER: {FFFFFF}/invite /uninvite /setrank /adjustrankname /newsvault /vaultwithdraw");
    // Los Santos Emergency Services
    if(IsAMedic(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "EMS: {FFFFFF} /heal /surgery /flashlights");
    if(IsAMedic(playerid) && PlayerInfo[playerid][pFacLeader]) SendClientMessage(playerid, COLOR_YELLOW, "EMS FACTION LEADER: {FFFFFF}/invite /uninvite /setrank /adjustrankname");
    return 1;
}
Reply
#8

Thanks , it worked, 9 warnings remaining.

pawn Код:
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(981) : warning 225: unreachable code
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(1046) : warning 225: unreachable code
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(1055) : warning 209: function "LoadFactions" should return a value
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(19057) : warning 202: number of arguments does not match definition
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(19058) : warning 202: number of arguments does not match definition
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(19059) : warning 202: number of arguments does not match definition
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(19060) : warning 202: number of arguments does not match definition
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(19061) : warning 202: number of arguments does not match definition
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(19062) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


9 Warnings.
Reply
#9

return statement finishes function and returns a value.

pawn Код:
stock Foo() {
    return 1;
    print("Hello there!");
}
This will return unreachable code, because the print will never be fired. Now find similar cases in your code and you have 2 problems less
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)