17.11.2009, 19:18
Quote:
Originally Posted by Ritchie999
I assign the skins, for police i use skins 280 to 286 and for the gangs i use all the gang skins. so basically, the leader of the gang invites people, and when they quit and re-join they are still in the gang but they have to be invited into the faction to join it |
So first your gonna need a Saving system, if you already have on and understand it well then skip this step.
http://forum.sa-mp.com/index.php?topic=126584.0
Very simple tutorial to make a dini saving system.
After you set up your players save files, it's time we add the variables for players stats.
under the enum pInfo.
pawn Code:
enum pInfo
{
/* The stuff in the tutorial */,
pTeam,
pLeader,
}
For dini look for dini_IntSet(file, "name", somthing);
add the two saves for Team, and Leader.
After you do that, under the /login command, create the function that will load the Team save, and Leader Save, and set it to pTeam, and pLeader.
pawn Code:
gTeam = dini_Set(file, "Team")
pawn Code:
if(strcmp(cmd, "/invite", true) == 0)
{
if(PlayerInfo[playerid][Leader] == 1)
{
if(gTeam[playerid] == 1)
{
if(!strlen(cmd[7])) return SendClientMessage(playerid, 0xAFAFAFAA, "USAGE: /invite [playerid]");
new otherplayerid = strval(cmdtext[9]);
if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, 0xAFAFAFAA, "That player isnt connected");
if(otherplayerid == playerid) return SendClientMessage(playerid, 0xFF0000AA, "You cannot invite yourself!!");
new gstring[128], string2[128];
new adminname[MAX_PLAYER_NAME], otherguysname[MAX_PLAYER_NAME];
GetPlayerName(playerid,adminname,sizeof(adminname));
GetPlayerName(otherplayerid,otherguysname,sizeof(otherguysname));
format(gstring,sizeof(gstring),"** You have invited %s", otherguysname);
format(string2,sizeof(string2),"** You were invited to join a faction by %s", adminname);
SendClientMessage(playerid, 0x00E100FF, gstring);
SendClientMessage(otherplayerid, 0x00E100FF, string2);
gTeam[otherplayerid] = 1;
SetPlayerHealth(otherplayerid, 0.00 );
return 1;
}
return 1;
}
if(PlayerInfo[playerid][Leader] == 1)
{
if(gTeam[playerid] == 2)
{
if(!strlen(cmd[7])) return SendClientMessage(playerid, 0xAFAFAFAA, "USAGE: /invite [playerid]");
new otherplayerid = strval(cmdtext[9]);
if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, 0xAFAFAFAA, "That player isnt connected");
if(otherplayerid == playerid) return SendClientMessage(playerid, 0xFF0000AA, "You cannot invite yourself!!");
new gstring[128], string2[128];
new adminname[MAX_PLAYER_NAME], otherguysname[MAX_PLAYER_NAME];
GetPlayerName(playerid,adminname,sizeof(adminname));
GetPlayerName(otherplayerid,otherguysname,sizeof(otherguysname));
format(gstring,sizeof(gstring),"** You have invited %s", otherguysname);
format(string2,sizeof(string2),"** You were invited to join a faction by %s", adminname);
SendClientMessage(playerid, 0x00E100FF, gstring);
SendClientMessage(otherplayerid, 0x00E100FF, string2);
gTeam[otherplayerid] = 2;
SetPlayerHealth(otherplayerid, 0.00 );
return 1;
}
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED, "Only Leaders can Invite.");
return 1;
}
}
The pLeader is there to make sure the leader is the only one who can invite.
You can do even more, such as pick skins, and respawn the player.