enum Question. -
SilencedPistol - 09.05.2013
Okay, so I'm making a faction system and my main player enum is pInfo which has like pName, pPass, pSkin and stuff within it.
So what I'm asking is, how would I alter my enum to accommodate a faction system? Do I put pFaction, pRank and stuff within my pInfo enum, or create a separate enum like pFaction or something?
Re: enum Question. -
IceCube! - 09.05.2013
Removed: The guy below is willing to go into more detail for you on here, I however dont have the paitience to do such as thing on here so I'll withdraw this comment.
Re: enum Question. -
Scenario - 09.05.2013
This actually depends on how you plan to structure your faction system...
You can do it many different ways. You can make it so a person can be in a virtually unlimited amount of factions, make them allowed to be in a single faction, or in a set number of factions.
Furthermore, you can also make the faction system where ranks are dynamic (meaning instead of having 12 set ranks, you can have as many as you need/want) and/or where each "rank" has a different "rank description."
The possibilities are endless. So, tell me how you want to accomplish this so we can proceed further.
Re : enum Question. -
Rayan_black - 09.05.2013
You can use the same enum if you want, but I prefer using different enums for each system I do so just:
pawn Код:
enum fInfo
{
pOwner,
pMembers,
pRank,
blabla...etc..
}
new FactionInfo[MAX_PLAYERS][fInfo]
Re: enum Question. -
SilencedPistol - 09.05.2013
Well RealCop, I'd like a dynamic faction system with a few commands and such. If you want, we can take this to PMs so we can get in contact more directly?
Re: enum Question. -
Scenario - 09.05.2013
There's no point in taking this into a private discussion. There are 12,000 other coders on this forum that might assist you faster than I can in some aspects.
What's your saving system?
Re: enum Question. -
SilencedPistol - 09.05.2013
y_ini and also using ZCMD for processing. Ultimatley and eventually, I want everything dynamic, I'll go into detail here.
/factionlist - Displays a list of 10 factions (maximum is 10). Each faction will be given an ID from 1 - 10.
/makeleader [playerid] [factionid] - Sets the playerid as leader of that faction ID.
/invite [playerid] - For use by higher faction ranks.
/uninvited [playerid] - For use by higher faction ranks.
/renamefaction [factionid] - Renames the factions name on /factionlist.
/setrank [playerid] [custom rank name] - Sets players name.
That's basically what I want eventually. I aint asking you for a code, just how would I go about arranging things so that I can make all that I want work?
Re: enum Question. -
Scenario - 09.05.2013
One more question; How many factions can a player be in at once?
Re: enum Question. -
SilencedPistol - 09.05.2013
Oh, just a maximum of 1 faction.
Re: enum Question. -
Scenario - 10.05.2013
I apologize for the delayed response; had some stuff to take care of personally.
Let's begin working with the saving system. Now, bare in mind I don't know how y_ini works, but it should still be simple enough to allow me to explain this to you.
You said you only want 10 factions; so you're basically going to have one file per faction. In each file would be the following variables:
factionName
factionType (i.e. 1 = normal; 2 = LAW; 3 = EMS; 4 = GOV - we do this to determine command permissions)
factionRanks
Now, this is where it could get interesting. Upon creating the faction you COULD make it so you can set the number of ranks that the faction will have. Basically, you'll ask the administrator creating the faction how many ranks will be created. They'll input a number (for this example, let's say 15) and you'll set "factionRanks" to 15. Now, you'll ask them to input a rank name per each rank number. So, in total, they need 15 rank names.
In the file, you can format the "factionRankX" line where X is the rank number. I feel like this piece of code could assist in showing you how this is done.
pawn Код:
public OnDialogResponse(...)
{
switch(dialogid)
{
case DIALOG_NAME:
{
if(response)
{
CreatingFactionRank[playerid]++; // see below
if(CreatingFactionRank[playerid] <= CreatingFactionTotalRanks[playerid]) // check to see if we've reached the amount of ranks we're creating..
{
// okay, so let's say that "inputtext" is the faction rank name; what we're going to do is open the .ini file of the faction and format this string:
format(szString, sizeof(szString), "factionRank%d", CreatingFactionRank[playerid]); // CreatingFactionRank[playerid] should increase on each dialog response
// it will tell us which number we're editing per each dialog response
WRITE FORMAT TO FILE HERE
// now we can format a new line so we can tell the admin which faction rank they're editing
format(szString, sizeof(szString), "You're now editing rank %d.\n\nPlease write the rank name below.", CreatingFactionRank[playerid]);
ShowPlayerDialog(playerid, DIALOG_ID, DIALOG_STYLE_INPUT, "Creating a Faction - Setting Rank Names", szString, "Submit", "Close");
}
}
}
}
return 1;
}
Let's say you had
10 ranks. The faction's file would look like this:
The faction ID would serve as its file name. The contents would include the following:
factionName = Los Santos Police Department
factionType = 2
factionRanks = 10
factionRank1 = Chief of Police
factionRank2 = Deputy Chief of Police
factionRank3 = Commander
factionRank4 = Captain
factionRank5 = Lieutenant
factionRank6 = Senior Lead Officer
factionRank7 = Police Officer III
factionRank8 = Police Officer II
factionRank9 = Police Officer I
factionRank10 = Probationary Officer
And, as far as I can see, you would be done with the creation of the faction.
When you load the faction, you'll need to load "factionRanks" and then make sure you use a format to load each faction rank depending on how many there are. Just keep in mind that everything has a limit. If you want "unlimited" ranks, just set it to like 30. Nobody will ever hit 30 ranks in a single faction- that's overkill.
As far as putting people in a faction is concerned, they just need two additional variables. They would be "pFaction" and "pRank".
At runtime, you would load all of the factions into their own enum and so when you need to figure out someone's rank name you would use the "pRank" variable to determine which rank number it is. Let me know if you need an example.
I hope this helps!