14.12.2016, 11:29
It's a function, not a stock, don't use the keyword stock, the keyword stock is used to silence that function, stock is used in includes, not gamemodes/ filterscripts.
Instead of making a function like this, simply make an array, and make a little function that returns the rank name from the array.
Also, the errors and warnings are coming up because of something different, encourage and promote 'productive' code writing. Check lines above 260.
Your code:
My code:
My code is secured as I am using constant array, faster and better.
Instead of making a function like this, simply make an array, and make a little function that returns the rank name from the array.
Also, the errors and warnings are coming up because of something different, encourage and promote 'productive' code writing. Check lines above 260.
Your code:
PHP Code:
stock GetPDRank(playerid)
{
new ranks = PlayerInfo[playerid][pRank];
new rankname[37];
switch(ranks)
{
case 1: rankname = "Chief of Police";
case 2: rankname = "Assistant Chief of Police";
case 3: rankname = "Deputy Chief of Police";
case 4: rankname = "Lieutenant";
case 5: rankname = "Captain";
case 6: rankname = "Commander";
case 7: rankname = "Police Sergeant II";
case 8: rankname = "Police Sergeant I";
case 9: rankname = "Detective III";
case 10: rankname = "Detective II";
case 11: rankname = "Detective I";
case 12: rankname = "LIO/SLO";
case 13: rankname = "Police Officer III";
case 14: rankname = "Police Officer II";
case 15: rankname = "Polife Officer I";
case 16: rankname = "Academy Student";
case 17: rankname = "Suspended Officer";
}
return rankname;
}
PHP Code:
enum e_fGovernment
{
RankName[37]
};
new const fGovernment[][e_fGovernment] =
{
"-", // enums and arrays start from 0, rank 0 is nothing
"Mayor", // rank 1
"Deputy Mayor" // rank 2 and so on...
};
GetGovRank(playerid) return fGovernment[PlayerInfo[playerid][pRank]][RankName];