Help With Factions!
#1

Hello, I've only just started scripting in Pawno and I need some help with creating Factions. If someone could explain how to add commands like /invite [ID] for Faction leaders to invite other players to the faction. Also /uninvite to do the opposite, and how would I make vehicles available to only faction members. I'm looking to make Government Factions like LSPD and LSES (Los Santos Emergency Services), does anyone know anything about that, like /cuff, /arrest and /onduty.

Any help would be great.
Reply
#2

An enum or a simple variable can do the trick. I'll give an example of both.

Enum
An enum; in laymens terms is basically a more efficient way of defining variables. Notice how the enum [Info]'s match?
pawn Код:
enum Info
{
    pFaction,
}
new pInfo[MAX_PLAYERS][Info];
Variable
This is shorter, and is not recommended if you're planning on saving multiple RP stats.
pawn Код:
new pFaction[MAX_PLAYERS];
Note: Before checking out this next section. I strongly suggest you learn how to use ZCMD and sscanf.
Commands

Now once you have your variables. Let's make an example command.

pawn Код:
CMD:invite(playerid,params[])
{
    new targetid;
    if(sscanf(params,"u",targetid)) return SendClientMessage(playerid,0xC0C0C0FF,"USAGE: /invite [playerid]");

    else
    {
        pInfo[playerid][pFaction] = 1;
        return 1;
    }
}
Explanation

This defines a new variable that will hold the id of the player that you want to invite.

pawn Код:
new targetid;
This will check if the player who typed the command left the rest of the command empty and will return a message stating how to use the command.
pawn Код:
if(sscanf(params,"u",targetid)) return SendClientMessage(playerid,0xC0C0C0FF,"USAGE: /invite [playerid]");
This will initiate if the player types the rest of the command.

pawn Код:
else
    {
        pInfo[playerid][pFaction] = 1;
        return 1;
    }
This is the part that actually sets the target ids faction to 1 or the LSPD.

pawn Код:
pInfo[playerid][pFaction] = 1;
Conclusion

This was just a real basic touch of how to do it. My fault, because I know I didn't go in depth because I really don't have the time to write a whole tutorial. Just get creative. Learn sscanf and ZCMD, and educate yourself. Goodluck!
Reply
#3

Ok thanks, its a little bit advanced for me but I will educate myself.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)