Faction system
#1

Hey guys, i have a question about how can i make a faction system with 0 to 7 ranks each rank with a asigned skin in zcmd?

i need the faction cmd first or the faction system first?
Reply
#2

First you need to add faction-related data, then you need to write commands appropriate to your faction IMHO.
E.g. first you create an enum of faction data which you'll save this way or another, and players' data related to faction, obviously, somewhat like...

Код:
#define MAX_FACTIONS 10 //You don't really have to define that if you have fixed amount of factions.

enum fData
{
   fName[64], //If you need it
   fRSkin[7],
   fColor, //just like faction name, if you need it
   ...
}

enum pData
{
   ...
   pSkin, //I'll assume you store the skin because it's reasonable to do so.
   ...
   pFaction,
   pFactionRank,
   ...
}

...

new FactionInfo[MAX_FACTIONS][fData] //or new FactionInfo[10][fData] if you're sure you'll always have 10 factions.
new PlayerInfo[MAX_PLAYERS][pInfo]
Then, let's say if you want to have a skin change in some certain position (e.g. pickup or just some point in the game), you'll do smth like that

Код:
COMMAND:factionskin(playerid)
{
   //First we check if the player is in the faction corresponding to that clothes change location. I'll assume pFaction is a variable holding player faction ID, whilst PlayerInfo is a variable that allows you to access player data.
   if(PlayerInfo[playerid][pFaction] == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not in a faction!");
   //Then I'd check whether the player is around the point
   if(!IsPlayerInRangeOfPoint(playerid, range, x, y, z)) return SendClientMessage(playerid, 0xFFFFFFFF, "You need to be at the place where you can change your clothes!");
   //Depending on the faction you might want to check for different positions; you might even store those clothes changing positions somewhere in the faction data, if you want. Just remember that they are defined like Float:variablename, since coordinates are float values.
   //Once we're through with these checks, we can get to setting player skin depending on his rank. Let's say his faction rank is stored in pFactionRank variable.
   new skin = FactionInfo[ PlayerInfo[playerid][pFaction] - 1 ][fRSkin][ PlayerInfo[playerid][pFactionRank] - 1 ];
   //The reason why I have -1 there is because arrays start from 0, as we all surely know. You can take any other approach you like, e.g. making number of factions +1 to then start from 1 if it makes you comfortable.
   SetPlayerSkin(playerid, skin);
   PlayerInfo[playerid][pSkin] = skin;
   //Of course, once done, you can send a message to the player.
   SendClientMessage(playerid, 0xFFFFFFFF, "You have changed your clothes!");
   return 1;//All commands must return a value.
}
Might be incorrect if you have different vision on how-to's, but I guess that gives you the general idea of how it works. In general though, just try and define most of the variables you believe you need, then you'll add as many as you need in the script throughout the coding process; I am assured that's how everyone does that - and I personally do so, too, since sometimes I never know what kind of feature I'll add next.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)