SA-MP Forums Archive
[VIP] Tag - 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: [VIP] Tag (/showthread.php?tid=380545)



[VIP] Tag - Blackazur - 25.09.2012

How can i add that VIP's have a [VIP] Tag before he Name? So i have define VIP:

Quote:

if(VIP[playerid] == 1)




Re: [VIP] Tag - clarencecuzz - 26.09.2012

This is a rough estimate of how it should work. If there's any mistakes, give me some slack because I did it on notepad instead of pawno.

pawn Код:
public OnGameModeInit() //or OnFilterScriptInit for Filterscripts
{
    SetTimer("VIPCHECK", 5000, true);
    return 1;
}

forward VIPCHECK();
public VIPCHECK()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            new PLAYERSNAME[MAX_PLAYER_NAME];
            GetPlayerName(i, PLAYERSNAME, MAX_PLAYER_NAME);
            if(VIP[i] > 0)
            {
                SetPlayerColor(i, 0xFF0000FF); //Change 0xFF0000FF (Red) with whatever color you want your VIPs to be
                if(strfind(PLAYERSNAME, "[VIP]", true) == -1 || strfind(PLAYERSNAME, "VIP_", true) == -1) //-1 because it was 'not found'
                {
                    new newname[MAX_PLAYER_NAME];
                    if(strlen(PLAYERSNAME) >= 20)
                    {
                        format(newname, sizeof(newname),"VIP_%s",PLAYERSNAME);
                    }
                    else
                    {
                        format(newname,sizeof(newname),"[VIP]%s",PLAYERSNAME);
                    }
                    SetPlayerName(i, newname);
                }
            }
            else
            {
                //SetPlayerColor(i, 0x00FF00FF); //Optional, but you can use this to set regular player's colours.
                if(strfind(PLAYERSNAME,"[VIP]", true) != -1)
                {
                    new found = strfind(PLAYERSNAME, "[VIP]", true);
                    strdel(PLAYERSNAME, found, found + 4);
                    SetPlayerName(i, PLAYERSNAME);
                }
                else if(strfind(PLAYERSNAME, "VIP_", true) != -1)
                {
                    new found = strfind(PLAYERSNAME, "VIP_", true);
                    strdel(PLAYERSNAME, found, found + 3);
                    SetPlayerName(i, PLAYERSNAME);
                }
            }
        }
    }
    return 1;
}
EDIT: I added it to a timer, because you probably didn't want it under OnPlayerSpawn...
EDIT #2: I also realised that you had a thread for VIP Color, so I added that aswell.