SA:MP Factions - Create factions, add or remove players from them, enable friendly fire for deathmatch zones, create faction commands and faction properties.
- Start to use by creating a team.
CreateFaction("Amazing people");
- After you've created a faction, add the player to that faction.
@command(.type = SLASH_COMMAND) joinamazing(playerid, params[])
{
SendClientMessage(playerid, -1, "You're now amazing.");
AddPlayerToFaction(playerid, "Amazing people");
return 1;
}
- You can create a normal slash command so the player can join the faction at anytime. To remove a player from a faction, use a same function.
@command(.type = SLASH_COMMAND) quitamazing(playerid, params[])
{
SendClientMessage(playerid, -1, "You aren't amazing anymore.");
SetPlayerFaction(playerid, "NO_FACTION"); // 'NO_FACTION' is a 'hardcoded' internal faction which can't be deleted or either recreated.
// To remove player from a faction, just use 'NO_FACTION' for a faction name.
return 1;
}
- Let's take a look at all of the include features, including visual ones and scripting functions.
- New features regarding to other libraries!
- Including
d_factions.inc
extends the some of the possibilities provided byd_commands.inc
. Though, now you can create special faction commands, whose can be used only by a certain faction's members. Let's create one for a faction we made in the example above:
@command(.type = FACTION_COMMAND, .faction = "Amazing people") amiamazing(playerid, params[])
{
SendClientMessage(playerid, -1, "You are amazing!");
return 1;
}
- Also, including d_factions.inc extends the capabilities of d_properties.inc, which means you can also create factions properties - properties whose can be accessed only by a certain factions. Creating those properties is easy to do, you only add an extra parameter next to property name - factions name. So to create a property for a faction we made in the example:
CreateFactionPropertyEntrance("Your Interior", "Amazing people", 825.6589,-1614.8202,13.5469, 0, 0, true, INTERIOR_CUSTOM, 0.0000, 0.0000, 4.0000, 1, 1);
- Including
d_factions
will give you new faction permissions. When a faction permission is set, all of the certain faction members will have THOSE permissions. Modifying permissions for a player which is in a faction will not work. Note that faction permission features will be only possible ifd_permissions
is included. You can modify permissions only for factions using:
SetFactionPermissionInteger("Amazing people", DEFAULT_PLAYER_PERMISSIONS);
- Functions provided.
- Create a faction.
- Delete a faction.
DeleteFaction("Amazing people");
- Get the member count of a certain faction.
GetFactionMemberCount("Amazing people");
- Set the player's current faction.
- Get the player's faction.
new faction[32];
GetPlayerFaction(playerid, faction);
// Now you're supposed to use the "faction" string
- Create a property for a certain faction. Note that this works ONLY if the file
d_properties.inc
is included.
- Called whenever a certain faction is created.
public OnFactionCreate(factionid, factionname[])
{
printf("Team '%s'[%i] created.", factionname, factionid);
return 1;
}
- Called whenever a certain faction is deleted.
public OnFactionDelete(factionid, factionname[])
{
printf("Team '%s'[%i] deleted.", factionname, factionid);
return 1;
}
- Players within the same faction cannot harm each other.
SetPlayerFaction
only sets player's faction at ONCE, which means player can't be a member of more than one faction.- Player's faction is set to
NO_FACTION
after the player disconnects.
- No important notes yet.