stock GetFactionRankName(playerid)
{
new rankname[26];
if(pInfo[playerid][Faction] == 1)
{
if(pInfo[playerid][FactionRank] == 0)
rankname = "Police Officer I";
else if(pInfo[playerid][FactionRank] == 1)
rankname = "Police Officer II";
else if(pInfo[playerid][FactionRank] == 2)
rankname = "Police Officer III";
else if(pInfo[playerid][FactionRank] == 3)
rankname = "Lead Police Officer";
else if(pInfo[playerid][FactionRank] == 4)
rankname = "Sergeant I";
else if(pInfo[playerid][FactionRank] == 5)
rankname = "Sergeant II";
else if(pInfo[playerid][FactionRank] == 6)
rankname = "Sergeant III";
else if(pInfo[playerid][FactionRank] == 7)
rankname = "Lieutenant I";
else if(pInfo[playerid][FactionRank] == 8)
rankname = "Lieutenant II";
else if(pInfo[playerid][FactionRank] == 9)
rankname = "Lieutenant III";
else if(pInfo[playerid][FactionRank] == 10)
rankname = "Captain I";
else if(pInfo[playerid][FactionRank] == 11)
rankname = "Captain II";
else if(pInfo[playerid][FactionRank] == 12)
rankname = "Captain III";
else if(pInfo[playerid][FactionRank] == 13)
rankname = "Commander";
else if(pInfo[playerid][FactionRank] == 14)
rankname = "Assistant Chief of Police";
else if(pInfo[playerid][FactionRank] == 15)
rankname = "Deputy Chief of Police";
else if(pInfo[playerid][FactionRank] == 16)
rankname = "Chief of Police";
}
return rankname;
}
CMD:r(playerid, params[])
{
new string[128], pname[MAX_PLAYER_NAME+1], factionid = pInfo[playerid][Faction];
if(pInfo[playerid][Faction] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER:{FFFFFF} You're not in a faction!");
GetPlayerName(playerid, pname, sizeof(pname));
{format(string, sizeof(string), "%s %s: %s", GetFactionRankName(playerid), pname, params);}
SendFactionRadioMessage(factionid, string);
return 1;
}
stock GetFactionRankName(playerid)
{
new
rankName[26]
;
switch(pInfo[playerid][FactionRank])
{
case 0: strcat(rankName, "Police Officer I", sizeof(rankName));
case 1: strcat(rankName, "Police Officer II", sizeof(rankName));
case 2: strcat(rankName, "Police Officer III", sizeof(rankName));
case 3: strcat(rankName, "Lead Police Office", sizeof(rankName));
case 4: strcat(rankName, "Sergeant I", sizeof(rankName));
case 5: strcat(rankName, "Sergeant II", sizeof(rankName));
case 6: strcat(rankName, "Sergeant III", sizeof(rankName));
case 7: strcat(rankName, "Lieutenant I", sizeof(rankName));
case 8: strcat(rankName, "Lieutenant II", sizeof(rankName));
case 9: strcat(rankName, "Lieutenant III", sizeof(rankName));
case 10: strcat(rankName, "Captain I", sizeof(rankName));
case 11: strcat(rankName, "Captain II", sizeof(rankName));
case 12: strcat(rankName, "Captain III", sizeof(rankName));
case 13: strcat(rankName, "Commander", sizeof(rankName));
case 14: strcat(rankName, "Assistant Chief of Police", sizeof(rankName));
case 15: strcat(rankName, "Deputy Chief of Police", sizeof(rankName));
case 16: strcat(rankName, "Chief of Police", sizeof(rankName));
}
return rankName;
}
CMD:r(playerid, params[])
{
if(pInfo[playerid][Faction] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER:{FFFFFF} You're not in a faction!");
new
string[128],
pName[MAX_PLAYER_NAME],
factionID = pInfo[playerid][Faction]
;
GetPlayerName(playerid, pName, sizeof(pName));
format(string, sizeof(string), "%s %s: %s", GetFactionRankName(playerid), pName, params);
SendFactionRadioMessage(factionID, string);
return 1;
}
|
PHP код:
|
enum RankInfo {
fRankID,
fRank [ 32 ]
};
ReturnFactionRank( fid, rank ) {
new
rankEx [ 32 ];
switch ( fid ) { // switch through faction ids
case FACTION_POLICE: { // Case FACTION_POLICE aka 1...
new const RankArray[ ][ RankInfo ] = { // Matter of fact, you may not even need to add the IDs to the array
{ 1, "Police Officer I" }, { 2, "Police Officer II" }, { 3, "Police Officer III" }, { 4, "Lead Police Officer" }, { 5, "Sergeant I" },
{ 6, "Sergeant II" }, { 7, "Sergeant III" }, { 8, "Lieutenant I" }, { 9, "Lieutenant II" }, { 10, "Lieutenant III" }, { 11, "Captain I" },
{ 12, "Captain II" }, { 13, "Captain III" }, { 14, "Commander" }, { 15, "Assistant Chief of Police" }, { 16, "Deputy Chief of Police" },
{ 17, "Chief of Police" }
};
}
// case FACTION_MEDIC: { etc...
}
format ( rankEx, sizeof ( rankEx ), "%s", RankArray [ rank ] [ fRank ] );
if ( ! fid || ! rank )
rankEx = "None" ;
return rankEx;
}
new
p_fac [ MAX_PLAYERS char ],
p_facRank [ MAX_PLAYERS char ];
CMD:ranktest( pid, params [ ] ) {
new
str [ 144 ],
name [ MAX_PLAYER_NAME ] ;
GetPlayerName( pid, name, sizeof ( name ) ) ;
if ( ! p_fac { pid } )
return SendClientMessage ( pid, -1, "You're not in a faction!" );
if ( isnull ( params ) )
return SendClientMessage ( pid, -1, "/ranktest [ text ]" );
if ( strlen ( params ) > 110 ) // Perserving space for rank and name...
return SendClientMessage ( pid, -1, "Text can't have more than 110 characters!" );
format ( str, sizeof ( str ) , "%s %s: %s", ReturnFactionRank ( p_fac { pid }, p_facRank { pid } ), name, params);
ReturnFactionMsg ( p_fac { pid }, str );
return true;
}
ReturnFactionMsg ( fid, text [ ] )
{
foreach ( new i: Player)
{
if ( p_fac { i } == fid )
{
return SendClientMessage ( i, -1, text );
}
}
return false;
}
|
Pretty certain there was a rule against bumping topics within 24/48 hours. Either way...
Your script lacks a ton of debug lines. Also, you may not want to use switch / if ( x ) statements when you can use an array. And I'm pretty sure using strcat this way isn't really efficient... I'm also not a fan of huge functions like the one you use to return your rank. Why not something like this? PHP код:
PHP код:
|

stock GetFactionRankName(playerid)
{
new rankname[30];
switch(pInfo[playerid][Faction])
{
case 1:
{
//Faction 1
if(!pInfo[playerid][FactionRank])strcat(rankname,"Police Officer I");
else if(pInfo[playerid][FactionRank] == 1)strcat(rankname,"Police Officer II");
else if(pInfo[playerid][FactionRank] == 2)strcat(rankname,"Police Officer III");
else if(pInfo[playerid][FactionRank] == 3)strcat(rankname,"Lead Police Officer");
else if(pInfo[playerid][FactionRank] == 4)strcat(rankname,"Sergeant I");
else if(pInfo[playerid][FactionRank] == 5)strcat(rankname,"Sergeant II");
else if(pInfo[playerid][FactionRank] == 6)strcat(rankname,"Sergeant III");
else if(pInfo[playerid][FactionRank] == 7)strcat(rankname,"Lieutenant I");
else if(pInfo[playerid][FactionRank] == 8)strcat(rankname,"Lieutenant II");
else if(pInfo[playerid][FactionRank] == 9)strcat(rankname,"Lieutenant III");
else if(pInfo[playerid][FactionRank] == 10)strcat(rankname,"Captain I");
else if(pInfo[playerid][FactionRank] == 11)strcat(rankname,"Captain II");
else if(pInfo[playerid][FactionRank] == 12)strcat(rankname,"Captain III");
else if(pInfo[playerid][FactionRank] == 13)strcat(rankname,"Commander");
else if(pInfo[playerid][FactionRank] == 14)strcat(rankname,"Assistant Chief of Police");
else if(pInfo[playerid][FactionRank] == 15)strcat(rankname,"Deputy Chief of Police");
else if(pInfo[playerid][FactionRank] == 16)strcat(rankname,"Chief of Police");
return rankname;
}
}
return 1;
}
CMD:r(playerid,params[])
{
new string[145],pName[MAX_PLAYER_NAME],factionid = pInfo[playerid][Faction];
if(!factionid)return SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER:{FFFFFF} You're not in a faction!");
GetPlayerName(playerid,pname,sizeof pname);
format(string,sozeof string,"%s %s: %s",GetFactionRankName(playerid),pname,params);
SendFactionRadioMessage(factionid,string);
return 1;
}
C:\Users\Nathan\Desktop\Downtown Roleplay\gamemodes\core.pwn(4342) : error 079: inconsistent return types (array & non-array) Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 1 Error.
stock GetFactionRankName(playerid)
{
new rankname[30];
switch(pInfo[playerid][Faction])
{
case 1:
{
//Faction 1
if(!pInfo[playerid][FactionRank])strcat(rankname,"Police Officer I");
else if(pInfo[playerid][FactionRank] == 1)strcat(rankname,"Police Officer II");
else if(pInfo[playerid][FactionRank] == 2)strcat(rankname,"Police Officer III");
else if(pInfo[playerid][FactionRank] == 3)strcat(rankname,"Lead Police Officer");
else if(pInfo[playerid][FactionRank] == 4)strcat(rankname,"Sergeant I");
else if(pInfo[playerid][FactionRank] == 5)strcat(rankname,"Sergeant II");
else if(pInfo[playerid][FactionRank] == 6)strcat(rankname,"Sergeant III");
else if(pInfo[playerid][FactionRank] == 7)strcat(rankname,"Lieutenant I");
else if(pInfo[playerid][FactionRank] == 8)strcat(rankname,"Lieutenant II");
else if(pInfo[playerid][FactionRank] == 9)strcat(rankname,"Lieutenant III");
else if(pInfo[playerid][FactionRank] == 10)strcat(rankname,"Captain I");
else if(pInfo[playerid][FactionRank] == 11)strcat(rankname,"Captain II");
else if(pInfo[playerid][FactionRank] == 12)strcat(rankname,"Captain III");
else if(pInfo[playerid][FactionRank] == 13)strcat(rankname,"Commander");
else if(pInfo[playerid][FactionRank] == 14)strcat(rankname,"Assistant Chief of Police");
else if(pInfo[playerid][FactionRank] == 15)strcat(rankname,"Deputy Chief of Police");
else if(pInfo[playerid][FactionRank] == 16)strcat(rankname,"Chief of Police");
return rankname;
}
}
return 1;
}
stock GetFactionRankName(playerid)
{
new rankname[30];
switch(pInfo[playerid][Faction])
{
case 1:
{
//Faction 1
if(!pInfo[playerid][FactionRank])rankname="Police Officer I";
else if(pInfo[playerid][FactionRank] == 1)rankname="Police Officer II";
else if(pInfo[playerid][FactionRank] == 2)rankname="Police Officer III";
else if(pInfo[playerid][FactionRank] == 3)rankname="Lead Police Officer";
else if(pInfo[playerid][FactionRank] == 4)rankname="Sergeant I";
else if(pInfo[playerid][FactionRank] == 5)rankname="Sergeant II";
else if(pInfo[playerid][FactionRank] == 6)rankname="Sergeant III";
else if(pInfo[playerid][FactionRank] == 7)rankname="Lieutenant I";
else if(pInfo[playerid][FactionRank] == 8)rankname="Lieutenant II";
else if(pInfo[playerid][FactionRank] == 9)rankname="Lieutenant III";
else if(pInfo[playerid][FactionRank] == 10)rankname="Captain I";
else if(pInfo[playerid][FactionRank] == 11)rankname="Captain II";
else if(pInfo[playerid][FactionRank] == 12)rankname="Captain III";
else if(pInfo[playerid][FactionRank] == 13)rankname="Commander";
else if(pInfo[playerid][FactionRank] == 14)rankname="Assistant Chief of Police";
else if(pInfo[playerid][FactionRank] == 15)rankname="Deputy Chief of Police";
else if(pInfo[playerid][FactionRank] == 16)rankname="Chief of Police";
}
}
return rankname;
}