SA-MP Forums Archive
Member Help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Member Help (/showthread.php?tid=435516)



Member Help - CurlyPwn - 07.05.2013

Ok i have gangs now i just need a command that shows me the members in the gang can someone show me a example


Re: Member Help - Jstylezzz - 07.05.2013

Using ZCMD:
pawn Код:
CMD:members(playerid,params[])
{
    if(Gangvar[playerid] == 0) return SendClientMessage(playerid,-1,"You're not in any gang");//preventing the player from doing the command if he/she is not in a gang
    new string[128],pName[MAX_PLAYER_NAME];//declare the string which we're going to format a little later, aswell as the name string
    SendClientMessage(playerid,-1,"Current members online in your gang:");
    for(new i=0; i < MAX_PLAYERS; i++)//here we loop trough all players online at the moment
    {
        if(Gangvar[i] == Gangvar[playerid])//if the player is in the same gang as the command executer, continue
        {
        GetPlayerName(i,pName,MAX_PLAYER_NAME);//format the name string with the member's name
        format(string,sizeof(string),"* %s",pName);//format the string with the name of the online member
        SendClientMessage(playerid,-1,string);//send the formatted string to the player
        }
    }
    return 1;//to let the script know this was a valid command
}
You can't just copy/paste this code, since it does not contain the variables you use (probably). Check the comments I put behind each line, they explain exactly what happens.


Re: Member Help - CurlyPwn - 07.05.2013

Im Using OnPlayerCommandText


Re: Member Help - CurlyPwn - 07.05.2013

i made a enum for the gangmembers do i need it?

Quote:

enum gMember
{
pGrove,
pBallas,
pAztecas,
pVagos,
pRifa,
pTriads,
pNang,
pMafia
}
new GangMembers[MAX_PLAYERS][gMember];




Re: Member Help - Jstylezzz - 07.05.2013

It's exactly the same idea, it would look like this:
pawn Код:
if(!strcmp(cmdtext, "/members"))
    {
    if(Gangvar[playerid] == 0) return SendClientMessage(playerid,-1,"You're not in any gang");//preventing the player from doing the command if he/she is not in a gang
    new string[128],pName[MAX_PLAYER_NAME];//declare the string which we're going to format a little later, aswell as the name string
    SendClientMessage(playerid,-1,"Current members online in your gang:");
    for(new i=0; i < MAX_PLAYERS; i++)//here we loop trough all players online at the moment
    {
        if(Gangvar[i] == Gangvar[playerid])//if the player is in the same gang as the command executer, continue
        {
        GetPlayerName(i,pName,MAX_PLAYER_NAME);//format the name string with the member's name
        format(string,sizeof(string),"* %s",pName);//format the string with the name of the online member
        SendClientMessage(playerid,-1,string);//send the formatted string to the player
        }
    }
    return 1;//to let the script know this was a valid command
}
It's recommended that you upgrade to ZCMD or y_cmd by the way.

EDIT: I'm not sure how your system works, but I think you need to replace the Gangvar with the var you use for your enum (I can't be sure since I don't know how you use it).
((Remember, don't double post!))

Personally I wouldn't create a new enum to identify the gangs, I would just add pGang or something in the player enum, because it's easier to loop trough that, using only PlayerEnum[playerid][Gang] == 1, like so.


Re: Member Help - CurlyPwn - 07.05.2013

Lol i dont understand your command... i dont understand which i need to replace and i find onplayercommandtext easy for me sorry :/


Re: Member Help - Jstylezzz - 07.05.2013

You don't have to upgrade if you don't want
pawn Код:
Gangvar[playerid] == 0
The code above has to be replaced with the variable you use to define your gangs.


Re: Member Help - CurlyPwn - 07.05.2013

Quote:

enum gInfo
{
pGrove,
pBallas,
pAztecas,
pVagos,
pRifa,
pTriads,
pNang,
pMafia
}
new GangInfo[MAX_PLAYERS][gInfo];

This is what im using for the gangs


Re: Member Help - Pottus - 07.05.2013

Obviously you didn't script this if your asking if you need a enum that you created.


Re: Member Help - CurlyPwn - 07.05.2013

lol do u read?
Quote:

Ok i have gangs now i just need a command that shows me the members in the gang can someone show me a example

i needed this i remebered i had the enum and wanted to check if i needed it when i place the command -.-