Change name gang members
#1

i using this filterscript for creating gangs: https://sampforum.blast.hk/showthread.php?tid=261411

how to make when someone invite somebody then this player which is invited to get in his nick tag of gang in which he is invited!

this is command when someone allow invite for gang:

Код:
	if(strcmp(tmp, "join", true) == 0)
	{
		if(PlayerGang[playerid] != 0) return SendClientMessage(playerid, RandomColors[random(200)], "You must leave your gang first");
		if(invited[playerid] == 0) return SendClientMessage(playerid, RandomColors[random(200)], "You were not invited in any gang");
		JoinGang(playerid, invited[playerid]);
		return 1;
	}
this is callback of joining in gang:

Код:
public JoinGang(playerid, gangid)
{
	new file[100];
	new name[MAX_PLAYER_NAME];
	new gfile[100];
	format(gfile, sizeof(gfile), GANG_FILE, gangid);
	GetPlayerName(playerid, name, sizeof(name));
	format(file, sizeof(file), NAME_FILE, name);
 	dini_IntSet(file, "PGANG", gangid);
	new string[256];
	new stringeng[256];
	PlayerGang[playerid] = gangid;
	GangInfo[gangid][GANG_MEMBERS]++;
	if(ITA[playerid]) format(string, sizeof(string), "Sei entrato a far parte della gang %s, Membri: %d", GangInfo[gangid][GANG_NAME], GangInfo[gangid][GANG_MEMBERS]);
	else format(string, sizeof(string), "You joined the gang %s, Members: %d", GangInfo[gangid][GANG_NAME], GangInfo[gangid][GANG_MEMBERS]);
	SendClientMessage(playerid, RandomColors[random(200)], string);
	format(string, sizeof(string), "%s č entrato a far parte della gang %s", name , GangInfo[gangid][GANG_NAME]);
	format(stringeng, sizeof(stringeng), "%s Has joined the gang %s", name , GangInfo[gangid][GANG_NAME]);
	Message2All(string, stringeng);
	SetPlayerColor(playerid, GangInfo[gangid][GANG_COLOR]);
	
	dini_IntSet(gfile, "GANG_MEMBERS", GangInfo[gangid][GANG_MEMBERS]);
	return 1;
}
Reply
#2

pawn Код:
public JoinGang(playerid, gangid)
{
    new file[100];
    new name[MAX_PLAYER_NAME];
    new gfile[100];
    format(gfile, sizeof(gfile), GANG_FILE, gangid);
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), NAME_FILE, name);
    dini_IntSet(file, "PGANG", gangid);
    new string[256];
        format(string, sizeof(string), "[%s]%s", GangInfo[gangid][GANG_NAME], name);
        SetPlayerName(playerid, string);
    new stringeng[256];
    PlayerGang[playerid] = gangid;
    GangInfo[gangid][GANG_MEMBERS]++;
    if(ITA[playerid]) format(string, sizeof(string), "Sei entrato a far parte della gang %s, Membri: %d", GangInfo[gangid][GANG_NAME], GangInfo[gangid][GANG_MEMBERS]);
    else format(string, sizeof(string), "You joined the gang %s, Members: %d", GangInfo[gangid][GANG_NAME], GangInfo[gangid][GANG_MEMBERS]);
    SendClientMessage(playerid, RandomColors[random(200)], string);
    format(string, sizeof(string), "%s č entrato a far parte della gang %s", name , GangInfo[gangid][GANG_NAME]);
    format(stringeng, sizeof(stringeng), "%s Has joined the gang %s", name , GangInfo[gangid][GANG_NAME]);
    Message2All(string, stringeng);
    SetPlayerColor(playerid, GangInfo[gangid][GANG_COLOR]);
   
    dini_IntSet(gfile, "GANG_MEMBERS", GangInfo[gangid][GANG_MEMBERS]);
    return 1;
}
Reply
#3

but if someone go quit of gang, will this name be deleted?
Reply
#4

No ... you would have to do something in LeaveGang to search through the player name and remove the tag, or save the old player name to a variable.
Reply
#5

Quote:
Originally Posted by Famalamalam
Посмотреть сообщение
No ... you would have to do something in LeaveGang to search through the player name and remove the tag, or save the old player name to a variable.
here is public:

Код:
public LeaveGang(playerid, gangid)
{
	new file[100];
	new name[MAX_PLAYER_NAME];
	new gfile[100];
	format(gfile, sizeof(gfile), GANG_FILE, gangid);
	GetPlayerName(playerid, name, sizeof(name));
	format(file, sizeof(file), NAME_FILE, name);
	dini_IntSet(file, "PGANG", 0);
	new string[256];
	new stringeng[256];
	if(ITA[playerid]) format(string, sizeof(string), "Hai lasciato la gang %s", GangInfo[gangid][GANG_NAME]);
	else format(string, sizeof(string), "You left the gang %s", GangInfo[gangid][GANG_NAME]);
	SendClientMessage(playerid, RandomColors[random(200)], string);
	format(string, sizeof(string), "%s ha lasciato la gang %s", name , GangInfo[gangid][GANG_NAME]);
	format(stringeng, sizeof(stringeng), "%s has left gang %s", name , GangInfo[gangid][GANG_NAME]);
	Message2All(string, stringeng);
	PlayerGang[playerid] = 0;
	GangInfo[gangid][GANG_MEMBERS]--;
	SetPlayerColor(playerid, RandomColors[random(200)]);
	if(GangInfo[gangid][GANG_MEMBERS] == 0) {
		format(string, sizeof(string), "La gang %s si č sciolta", GangInfo[gangid][GANG_NAME]);
		format(stringeng, sizeof(stringeng), "The gang %s was abandoned", GangInfo[gangid][GANG_NAME]);
		Message2All(string, stringeng);
		return dini_Remove(gfile);
	}
	dini_IntSet(gfile, "GANG_MEMBERS", GangInfo[gangid][GANG_MEMBERS]);
	return 1;
}
Reply
#6

add this at the top of your script with all the other "new":
pawn Код:
new pNameG[MAX_PLAYERS];
Then:

pawn Код:
public JoinGang(playerid, gangid)
{
    new file[100];
    new name[MAX_PLAYER_NAME];
    new gfile[100];
    format(gfile, sizeof(gfile), GANG_FILE, gangid);
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), NAME_FILE, name);
    dini_IntSet(file, "PGANG", gangid);
    new string[256];
    format(pNameG[playerid], 128, name);
        format(string, sizeof(string), "[%s]%s", GangInfo[gangid][GANG_NAME], name);
        SetPlayerName(playerid, string);
    new stringeng[256];
    PlayerGang[playerid] = gangid;
    GangInfo[gangid][GANG_MEMBERS]++;
    if(ITA[playerid]) format(string, sizeof(string), "Sei entrato a far parte della gang %s, Membri: %d", GangInfo[gangid][GANG_NAME], GangInfo[gangid][GANG_MEMBERS]);
    else format(string, sizeof(string), "You joined the gang %s, Members: %d", GangInfo[gangid][GANG_NAME], GangInfo[gangid][GANG_MEMBERS]);
    SendClientMessage(playerid, RandomColors[random(200)], string);
    format(string, sizeof(string), "%s č entrato a far parte della gang %s", name , GangInfo[gangid][GANG_NAME]);
    format(stringeng, sizeof(stringeng), "%s Has joined the gang %s", name , GangInfo[gangid][GANG_NAME]);
    Message2All(string, stringeng);
    SetPlayerColor(playerid, GangInfo[gangid][GANG_COLOR]);
   
    dini_IntSet(gfile, "GANG_MEMBERS", GangInfo[gangid][GANG_MEMBERS]);
    return 1;
}

and finally:

pawn Код:
public LeaveGang(playerid, gangid)
{
    new file[100];
    new name[MAX_PLAYER_NAME];
    new gfile[100];
    format(gfile, sizeof(gfile), GANG_FILE, gangid);
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), NAME_FILE, name);
    dini_IntSet(file, "PGANG", 0);
    new string[256];
    new stringeng[256];
    if(ITA[playerid]) format(string, sizeof(string), "Hai lasciato la gang %s", GangInfo[gangid][GANG_NAME]);
    else format(string, sizeof(string), "You left the gang %s", GangInfo[gangid][GANG_NAME]);
    SendClientMessage(playerid, RandomColors[random(200)], string);
    format(string, sizeof(string), "%s ha lasciato la gang %s", name , GangInfo[gangid][GANG_NAME]);
    format(stringeng, sizeof(stringeng), "%s has left gang %s", name , GangInfo[gangid][GANG_NAME]);
    Message2All(string, stringeng);
    PlayerGang[playerid] = 0;
    GangInfo[gangid][GANG_MEMBERS]--;
    SetPlayerColor(playerid, RandomColors[random(200)]);
    SetPlayerName(playerid, pNameG[playerid]);
    if(GangInfo[gangid][GANG_MEMBERS] == 0) {
        format(string, sizeof(string), "La gang %s si č sciolta", GangInfo[gangid][GANG_NAME]);
        format(stringeng, sizeof(stringeng), "The gang %s was abandoned", GangInfo[gangid][GANG_NAME]);
        Message2All(string, stringeng);
        return dini_Remove(gfile);
    }
    dini_IntSet(gfile, "GANG_MEMBERS", GangInfo[gangid][GANG_MEMBERS]);
    return 1;
}
Try that, untested but should work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)