• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] turf system
#1
the code i use for turf system 

Code:
forward OnPlayerEnterTurf(playerid, turf);
public OnPlayerEnterTurf(playerid, turf)
{
if(turf != -1)
{
new string[128];
    if(GetPVarInt(playerid, "TurfsTD") == 1)
    {
if(TurfsInfo[turf][TurfsGang] != 255)
{
    new hex, str[32];
    format(str, sizeof(str), "%x", FamilyInfo[TurfsInfo[turf][TurfsGang]][FamilyBandana]);
sscanf(str, "x", hex);
    format(string, sizeof(string), "%s", FamilyInfo[TurfsInfo[turf][TurfsGang]][FamilyName]);
PlayerTextDrawColor(playerid, Textdraw1s[playerid], hex);
    PlayerTextDrawSetString(playerid, Textdraw1s[playerid], string);
    PlayerTextDrawHide(playerid, Textdraw1s[playerid]);
    PlayerTextDrawShow(playerid, Textdraw1s[playerid]);

}
else
{
    PlayerTextDrawSetString(playerid, Textdraw1s[playerid], "Neutral");
PlayerTextDrawColor(playerid, Textdraw1s[playerid], -1);
PlayerTextDrawHide(playerid, Textdraw1s[playerid]);
  PlayerTextDrawShow(playerid, Textdraw1s[playerid]);
}

TextDrawShowForPlayer(playerid, Textdraw0s);
}

if(TurfsInfo[turf][TurfsDoing] == 1)
{
    if(PlayerInfo[playerid][pGang] < 255)
    {
    foreach(Player, i)
    {
        if(InTurf[i] == turf)
        {
            if(PlayerInfo[i][pGang] < 255)
            {
            SetPlayerMarkerForPlayer(playerid, i, FamilyInfo[PlayerInfo[i][pGang]][FamilyBandana];
            pBandana[i] = 1;
}

if(PlayerInfo[i][pFaction] > 0)
{
    SetPlayerMarkerForPlayerEx(playerid, i);
    pBandana[i] = 1;
}

SetPlayerMarkerForPlayer(i, playerid, FamilyInfo[PlayerInfo[playerid][pGang]][FamilyBandana]);
pBandana[playerid] = 1;
}
}
}

if(PlayerInfo[playerid][pFaction] > 0)
{
    foreach(Player, i)
    {
        if(InTurf[i] == turf)
        {
            if(PlayerInfo[i][pGang] < 255)
            {
            SetPlayerMarkerForPlayer(playerid, i, FamilyInfo[PlayerInfo[i][pGang]][FamilyBandana]);
            pBandana[i] = 1;
}

if(PlayerInfo[i][pFaction] > 0)
{
    SetPlayerMarkerForPlayerEx(playerid, i);
    pBandana[i] = 1;
}

SetPlayerMarkerForPlayerEx(i, playerid);
pBandana[playerid] = 1;
}
}
}
}
}
return 1;
}


CMD:captureturf(playerid, params[])
{
    if(InTurf[playerid] == -1) return SCM(playerid, -1, "You are not in any turfs.");
if(PlayerInfo[playerid][pGang] < 255)
{
    if(PlayerInfo[playerid][pRank] >= 4)
    {
    if(TurfsInfo[InTurf[playerid]][TurfsVulnerable] == 0) return SCM(playerid, COLOR_GRAD2, "This turf is not ready to be capped.");

new turf = InTurf[playerid];
new string[128];
new count = GetMembersInTurf(turf, PlayerInfo[playerid][pGang]);

new cops = GetFactionMembersInTurf(turf);

if(TurfsInfo[turf][TurfsgCap] == PlayerInfo[playerid][pGang]) return SCM(playerid, COLOR_GRAD2, "Your gang is already attempting to claim the turf!");
if(count >= 3)
{
    if(cops > 5) return SendClientMessage(playerid, COLOR_GREY, "You can't capture while there are Law Enforcements alive.");
    if(TurfsInfo[turf][TurfsTimer]) KillTimer(TurfsInfo[turf][TurfsTimer]);

        format(string, sizeof(string), "* %s is attempting to take %s for %s (15 minutes).", GetPlayerNameEx(playerid), TurfsInfo[turf][TurfsName], FamilyInfo[PlayerInfo[playerid][pGang]][FamilyName]);
SendClientMessageToAll(COLOR_YELLOW, string);

                TurfsInfo[turf][TurfshTime] = 15;
TurfsInfo[turf][TurfsTimer] = SetTimerEx("TurfCappings", 60000, 1, "id", playerid, turf);
GangZoneFlashForAll(TurfsInfo[turf][TurfID], COLOR_RED);
TurfsInfo[turf][TurfsDoing] = 1;
TurfsInfo[turf][TurfsgCap] = PlayerInfo[playerid][pGang];
format(TurfsInfo[turf][TurfsCappingName], MAX_PLAYER_NAME, "%s", GetPlayerNameEx(playerid));

OnPlayerEnterTurf(playerid, turf);

/*foreach(Player, i)
{
    if(InTurf[i] == InTurf[playerid])
    {
SetPlayerTurfColor(i);
}
}*/
}
else
{
    format(string, sizeof(string), "There must be atleast 3 in your gang inside turf. You only have %d in that turf.", GetMembersInTurf(turf, PlayerInfo[playerid][pGang]));
SCM(playerid, COLOR_GRAD2, string);
}
}
else return SCM(playerid, COLOR_GREY, "You must be atleast R4+ to capture turfs.");
}

if(PlayerInfo[playerid][pFaction] == 1 || PlayerInfo[playerid][pFaction] == 2 || PlayerInfo[playerid][pFaction] == 10)
{
    if(PlayerInfo[playerid][pRank] >= 4)
    {
    if(TurfsInfo[InTurf[playerid]][TurfsVulnerable] == 0) return SCM(playerid, COLOR_GRAD2, "This turf is not ready to be capped.");

new turf = InTurf[playerid];
new string[128];

new cappers = GetAGangMembersInTurf(turf, TurfsInfo[turf][TurfsgCap]);

new count = GetFactionMembersInTurf(turf);

if(TurfsInfo[turf][TurfsgCap] == 256) return SCM(playerid, COLOR_GRAD2, "Law Enforcement is already claiming the turf!");
if(count >= 5)
{
    if(cappers > 3) return SendClientMessage(playerid, COLOR_GREY, "You can't capture while there are Gang Members alive.");
    if(TurfsInfo[turf][TurfsTimer]) KillTimer(TurfsInfo[turf][TurfsTimer]);

        format(string, sizeof(string), "* %s is attempting to take %s for Law Enforcement (15 minutes).", GetPlayerNameEx(playerid), TurfsInfo[turf][TurfsName]);
SendClientMessageToAll(COLOR_YELLOW, string);

                TurfsInfo[turf][TurfshTime] = 15;
TurfsInfo[turf][TurfsTimer] = SetTimerEx("TurfCappingss", 60000, 1, "id", playerid, turf);
GangZoneFlashForAll(TurfsInfo[turf][TurfID], COLOR_RED);
TurfsInfo[turf][TurfsDoing] = 1;
TurfsInfo[turf][TurfsgCap] = 256;
format(TurfsInfo[turf][TurfsCappingName], MAX_PLAYER_NAME, "%s", GetPlayerNameEx(playerid));
OnPlayerEnterTurf(playerid, turf);

  /*foreach(Player, i)
{
    if(InTurf[i] == InTurf[playerid])
    {
SetPlayerTurfColor(i);
}
}*/
}
else
{
    format(string, sizeof(string), "There must be atleast 5 in your members inside turf. You only have %d in that turf.", GetFactionMembersInTurf(turf));
SCM(playerid, COLOR_GRAD2, string);
}
}
else return SCM(playerid, COLOR_GREY, "You must be atleast R4+ to capture turfs.");
}
return 1;
}


the error I'm encountering
Code:
C:\Users\User\Desktop\rsrp\gamemodes\RSG.pwn(36022) : error 001: expected token: ",", but found ";"
C:\Users\User\Desktop\rsrp\gamemodes\RSG.pwn(36023) : error 028: invalid subscript (not an array or too many subscripts): "pBandana"
C:\Users\User\Desktop\rsrp\gamemodes\RSG.pwn(36023) : warning 215: expression has no effect
C:\Users\User\Desktop\rsrp\gamemodes\RSG.pwn(36023) : error 001: expected token: ";", but found "]"
C:\Users\User\Desktop\rsrp\gamemodes\RSG.pwn(36023) : error 029: invalid expression, assumed zero
C:\Users\User\Desktop\rsrp\gamemodes\RSG.pwn(36023) : fatal error 107: too many error messages on one line


this line: if(TurfsInfo[turf][TurfsDoing] == 1)
{
    if(PlayerInfo[playerid][pGang] < 255)
    {
    foreach(Player, i)
    {
        if(InTurf[i] == turf)
        {
            if(PlayerInfo[i][pGang] < 255)
            {
            SetPlayerMarkerForPlayer(playerid, i, FamilyInfo[PlayerInfo[i][pGang]][FamilyBandana];
            pBandana[i] = 1;
}
  Reply
#2
Try this

Code:
forward OnPlayerEnterTurf(playerid, turf);
public OnPlayerEnterTurf(playerid, turf)
{
    if(turf != -1)
    {
        new string[128];
        if(GetPVarInt(playerid, "TurfsTD") == 1)
        {
            if(TurfsInfo[turf][TurfsGang] != 255)
            {
                new hex, str[32];
                format(str, sizeof(str), "%x", FamilyInfo[TurfsInfo[turf][TurfsGang]][FamilyBandana]);
                sscanf(str, "x", hex);
                format(string, sizeof(string), "%s", FamilyInfo[TurfsInfo[turf][TurfsGang]][FamilyName]);
                PlayerTextDrawColor(playerid, Textdraw1s[playerid], hex);
                PlayerTextDrawSetString(playerid, Textdraw1s[playerid], string);
                PlayerTextDrawHide(playerid, Textdraw1s[playerid]);
                PlayerTextDrawShow(playerid, Textdraw1s[playerid]);
            }
            else
            {
                PlayerTextDrawSetString(playerid, Textdraw1s[playerid], "Neutral");
                PlayerTextDrawColor(playerid, Textdraw1s[playerid], -1);
                PlayerTextDrawHide(playerid, Textdraw1s[playerid]);
                PlayerTextDrawShow(playerid, Textdraw1s[playerid]);
            }

            TextDrawShowForPlayer(playerid, Textdraw0s);
        }

        if(TurfsInfo[turf][TurfsDoing] == 1)
        {
            if(PlayerInfo[playerid][pGang] < 255)
            {
                foreach(Player, i)
                {
                    if(InTurf[i] == turf)
                    {
                        if(PlayerInfo[i][pGang] < 255)
                        {
                            SetPlayerMarkerForPlayer(playerid, i, FamilyInfo[PlayerInfo[i][pGang]][FamilyBandana]);
                            pBandana[i] = 1;
                        }
                        
                        if(PlayerInfo[i][pFaction] > 0)
                        {
                            SetPlayerMarkerForPlayerEx(playerid, i);
                            pBandana[i] = 1;
                        }

                        SetPlayerMarkerForPlayer(i, playerid, FamilyInfo[PlayerInfo[playerid][pGang]][FamilyBandana]);
                        pBandana[playerid] = 1;
                    }
                }
            }

            if(PlayerInfo[playerid][pFaction] > 0)
            {
                foreach(Player, i)
                {
                    if(InTurf[i] == turf)
                    {
                        if(PlayerInfo[i][pGang] < 255)
                        {
                            SetPlayerMarkerForPlayer(playerid, i, FamilyInfo[PlayerInfo[i][pGang]][FamilyBandana]);
                            pBandana[i] = 1;
                        }
                        
                        if(PlayerInfo[i][pFaction] > 0)
                        {
                            SetPlayerMarkerForPlayerEx(playerid, i);
                            pBandana[i] = 1;
                        }

                        SetPlayerMarkerForPlayerEx(i, playerid);
                        pBandana[playerid] = 1;
                    }
                }
            }
        }
    }
    return 1;
}
  Reply


Forum Jump: