SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 26/02/2013, 07:11 PM   #1
ghzspark
Big Clucker
 
Join Date: Feb 2011
Posts: 61
Reputation: 0
Default some help with a faction

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

pawn Code:
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 Code:
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 Code:
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 Code:
new FacInfo[MAX_FACTIONS][facInfo];
ghzspark is offline   Reply With Quote
Old 26/02/2013, 07:15 PM   #2
Jstylezzz
High-roller
 
Jstylezzz's Avatar
 
Join Date: Sep 2011
Location: Netherlands
Posts: 1,860
Reputation: 1572
Default Re: some help with a faction

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)
Jstylezzz is offline   Reply With Quote
Old 26/02/2013, 07:16 PM   #3
Mystique
Huge Clucker
 
Mystique's Avatar
 
Join Date: Nov 2009
Posts: 460
Reputation: 13
Default Re: some help with a faction

Message Removed
Mystique is offline   Reply With Quote
Old 26/02/2013, 07:16 PM   #4
Misiur
High-roller
 
Misiur's Avatar
 
Join Date: Jul 2009
Location: Poland
Posts: 2,528
Reputation: 556
Default Re: some help with a faction

Quote:
array index out of bounds (variable "FacInfo")
What do you need more?

pawn Code:
new A[6];
Max index is 5, not 6 - 6 is length, and first index is 0
Misiur is offline   Reply With Quote
Old 26/02/2013, 07:28 PM   #5
Oscii
Huge Clucker
 
Join Date: Mar 2012
Location: London, United Kingdom
Posts: 241
Reputation: 14
Default Re: some help with a faction

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

for example:

pawn Code:
enum FacInfo
{
    yourvariable,
    yourvariable,
}
Oscii is offline   Reply With Quote
Old 26/02/2013, 07:34 PM   #6
ghzspark
Big Clucker
 
Join Date: Feb 2011
Posts: 61
Reputation: 0
Default Re: some help with a faction

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

pawn Code:
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 Code:
format(file, sizeof(file), "factions/EMS.ini");

1046 line
pawn Code:
format(file, sizeof(file), "factions/EMS.ini");

1055 is a bracket, this is the full code
pawn Code:
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 Code:
if(IsAMedic(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "EMS: {FFFFFF} /heal /surgery /flashlights");

4887 is a bracket, this is the full code
pawn Code:
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 Code:
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
ghzspark is offline   Reply With Quote
Old 26/02/2013, 08:15 PM   #7
StuartD
Gangsta
 
StuartD's Avatar
 
Join Date: Jul 2012
Location: United Kingdom
Posts: 954
Reputation: 265
Default Re: some help with a faction

Try This for the FactionHelp one;

pawn Code:
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;
}
StuartD is offline   Reply With Quote
Old 27/02/2013, 05:40 PM   #8
ghzspark
Big Clucker
 
Join Date: Feb 2011
Posts: 61
Reputation: 0
Default Re: some help with a faction

Thanks , it worked, 9 warnings remaining.

pawn Code:
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.
ghzspark is offline   Reply With Quote
Old 27/02/2013, 05:48 PM   #9
Misiur
High-roller
 
Misiur's Avatar
 
Join Date: Jul 2009
Location: Poland
Posts: 2,528
Reputation: 556
Default Re: some help with a faction

return statement finishes function and returns a value.

pawn Code:
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
Misiur is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
faction help farris Help Archive 3 07/09/2010 01:51 AM
[HELP]Change faction's spawn (members in the faction, urban rp mod) KfirRP Help Archive 0 27/11/2009 09:39 AM
[Map] [MAP] Ls Faction Zones ( 4 Faction Zone ) Lynax Maps 7 14/09/2009 10:06 PM


All times are GMT. The time now is 09:22 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.