SA-MP Forums Archive
Gang zones, don't show for a player who just logged in. - 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: Gang zones, don't show for a player who just logged in. (/showthread.php?tid=613957)



Gang zones, don't show for a player who just logged in. - Luicy. - 02.08.2016

Hi, so..
I just realised, that while I'm creating my server..
The turfs doesn't load correctly..
I mean, the turf name do load correctly, so do x, and y coords, and so do the 'type'
But the leader does not show, neither the color.
So what's missing are;
Turf Color, Turf Border, Turf 'leader'.
Here's my GameModeInit code for turfs;
(I got my parts in seperate files to keep it simple.)
PHP код:
hook OnGameModeInit() {
    for(new 
zid 0zid MAX_TURFSzid++) {
        if(
SQL::RowExists("turfs""id"zid)) {
            new 
handle SQL::Open(SQL::READ"turfs""id"zid); 
            
SQL::ReadInt(handle"type"Turfs[zid][Type]); 
            
SQL::ReadInt(handle"owner"Turfs[zid][Owner]); 
            
SQL::ReadInt(handle"award"Turfs[zid][Award]); 
            
SQL::ReadInt(handle"team_award"Turfs[zid][TeamAward]); 
            
SQL::ReadString(handle"street"Turfs[zid][Street], 64); 
            
SQL::ReadFloat(handle"minx"Turfs[zid][MinX]); 
            
SQL::ReadFloat(handle"miny"Turfs[zid][MinY]); 
            
SQL::ReadFloat(handle"maxx"Turfs[zid][MaxX]); 
            
SQL::ReadFloat(handle"maxy"Turfs[zid][MaxY]); 
            
SQL::Close(handle);
            switch(
Turfs[zid][Owner]) {
                case 
TEAM_GROVETurfs[zid][ID]     =     GangZoneCreate(Turfs[zid][MinX], Turfs[zid][MinY], Turfs[zid][MaxX], Turfs[zid][MaxY], COLOR_TURF_GROVE001.50x000000FF);
                case 
TEAM_BALLASTurfs[zid][ID]     =     GangZoneCreate(Turfs[zid][MinX], Turfs[zid][MinY], Turfs[zid][MaxX], Turfs[zid][MaxY], COLOR_TURF_BALLAS001.50x000000FF);
                case 
TEAM_VAGOSTurfs[zid][ID]     =     GangZoneCreate(Turfs[zid][MinX], Turfs[zid][MinY], Turfs[zid][MaxX], Turfs[zid][MaxY], COLOR_TURF_VAGOS001.50x000000FF);
                case 
TEAM_AZTECASTurfs[zid][ID]     =     GangZoneCreate(Turfs[zid][MinX], Turfs[zid][MinY], Turfs[zid][MaxX], Turfs[zid][MaxY], COLOR_TURF_AZTECAS001.50x000000FF);
                case 
TEAM_BIKERSTurfs[zid][ID]     =     GangZoneCreate(Turfs[zid][MinX], Turfs[zid][MinY], Turfs[zid][MaxX], Turfs[zid][MaxY], COLOR_TURF_BIKERS001.50x000000FF);
                case 
TEAM_SHERIFFTurfs[zid][ID]     =     GangZoneCreate(Turfs[zid][MinX], Turfs[zid][MinY], Turfs[zid][MaxX], Turfs[zid][MaxY], COLOR_TURF_SHERIFF001.50x000000FF);
                case 
TEAM_POLICETurfs[zid][ID]     =     GangZoneCreate(Turfs[zid][MinX], Turfs[zid][MinY], Turfs[zid][MaxX], Turfs[zid][MaxY], COLOR_TURF_POLICE001.50x000000FF);
                default: 
Turfs[zid][ID]             =    GangZoneCreate(Turfs[zid][MinX], Turfs[zid][MinY], Turfs[zid][MaxX], Turfs[zid][MaxY], COLOR_TURF_NONE001.50x000000FF);
            }
        }
    }
    
printf("Number of gang zones: %i"CountAllGangZones());

The result from printf do show 7.
Код:
Number of teams: 7
Number of gang zones: 7
Number of vehicle models: 154
And if I'd use a command named /setownedturf, then it'll show the zone, leader, and textdraw color.
Code of setownedturf;
PHP код:
CMD:setownedturf(playeridparams[]) {
    if(
Account[playerid][Staff] > 4) {
        new 
team;
        if(!
sscanf(params"i"team)) {
            if(
IsPlayerInAnyGangZone(playerid)) {
                for(new 
zid 0zid MAX_TURFSzid++) {
                    if(
SQL::RowExists("turfs""id"zid) && IsPlayerInGangZone(playeridTurfs[zid][ID])) {
                        new 
string[128];
                        
format(string128"Admin %s forced turf %s to be owned by %s."GetName(playerid), Turfs[zid][Street], GetTeamName(team));
                        
SendClientMessageToAll(COLOR_DEFstring);
                        
Teams[Turfs[zid][Owner]][Turf]--;
                        
Teams[team][Turf]++;
                        
Turfs[zid][Owner] = team;
                        switch(
team) {
                            case 
TEAM_GROVEGangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_GROVE);
                            case 
TEAM_BALLASGangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_BALLAS);
                            case 
TEAM_VAGOSGangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_VAGOS);
                            case 
TEAM_AZTECASGangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_AZTECAS);
                            case 
TEAM_BIKERSGangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_BIKERS);
                            case 
TEAM_SHERIFFGangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_SHERIFF);
                            case 
TEAM_POLICEGangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_POLICE);
                        } 
                        for(new 
targetid 0targetid MAX_PLAYERStargetid++) {
                            if(
IsPlayerConnected(targetid) && IsPlayerInGangZone(targetidTurfs[zid][ID])) {
                                
PlayerTextDrawHide(targetidTextdraw0);
                                
PlayerTextDrawHide(targetidTextdraw1);
                                
PlayerTextDrawHide(targetidTextdraw2);
                                
PlayerTextDrawHide(targetidTextdraw3);
                                
PlayerTextDrawHide(targetidTextdraw4);
                                
PlayerTextDrawHide(targetidTextdraw5);
                                
PlayerTextDrawHide(targetidTextdraw6);
                                
PlayerTextDrawHide(targetidTextdraw7);
                                
PlayerTextDrawHide(targetidTextdraw8);
                                
PlayerTextDrawHide(targetidTextdraw_Grove);
                                
PlayerTextDrawHide(targetidTextdraw_Ballas);
                                
PlayerTextDrawHide(targetidTextdraw_Vagos);
                                
PlayerTextDrawHide(targetidTextdraw_Aztecas);
                                
PlayerTextDrawHide(targetidTextdraw_Bikers);
                                
PlayerTextDrawHide(targetidTextdraw_Sheriff);
                                
PlayerTextDrawHide(targetidTextdraw_Police);
                                
PlayerTextDrawHide(targetidTextdraw_None);
                                switch(
Turfs[zid][Owner]) {
                                    case 
TEAM_GROVE: {
                                        
PlayerTextDrawShow(targetidTextdraw_Grove);
                                        
PlayerTextDrawBoxColor(targetid,Textdraw1COLOR_TURF_GROVE);
                                        
PlayerTextDrawBoxColor(targetid,Textdraw2COLOR_TURF_GROVE);
                                    }
                                    case 
TEAM_BALLAS: {
                                        
PlayerTextDrawShow(targetidTextdraw_Ballas);
                                        
PlayerTextDrawBoxColor(targetid,Textdraw1COLOR_TURF_BALLAS);
                                        
PlayerTextDrawBoxColor(targetid,Textdraw2COLOR_TURF_BALLAS);
                                    }
                                    case 
TEAM_VAGOS: {
                                        
PlayerTextDrawShow(targetidTextdraw_Vagos);
                                        
PlayerTextDrawBoxColor(targetid,Textdraw1COLOR_TURF_VAGOS);
                                        
PlayerTextDrawBoxColor(targetid,Textdraw2COLOR_TURF_VAGOS);
                                    }
                                    case 
TEAM_AZTECAS: {
                                        
PlayerTextDrawShow(targetidTextdraw_Aztecas);
                                        
PlayerTextDrawBoxColor(targetid,Textdraw1COLOR_TURF_AZTECAS);
                                        
PlayerTextDrawBoxColor(targetid,Textdraw2COLOR_TURF_AZTECAS);
                                    }
                                    case 
TEAM_BIKERS: {
                                        
PlayerTextDrawShow(targetidTextdraw_Bikers);
                                        
PlayerTextDrawBoxColor(targetid,Textdraw1COLOR_TURF_BIKERS);
                                        
PlayerTextDrawBoxColor(targetid,Textdraw2COLOR_TURF_BIKERS);
                                    }
                                    case 
TEAM_SHERIFF: {
                                        
PlayerTextDrawShow(targetidTextdraw_Sheriff);
                                        
PlayerTextDrawBoxColor(targetid,Textdraw1COLOR_TURF_SHERIFF);
                                        
PlayerTextDrawBoxColor(targetid,Textdraw2COLOR_TURF_SHERIFF);
                                    }
                                    case 
TEAM_POLICE: {
                                        
PlayerTextDrawShow(targetidTextdraw_Police);
                                        
PlayerTextDrawBoxColor(targetid,Textdraw1COLOR_TURF_POLICE);
                                        
PlayerTextDrawBoxColor(targetid,Textdraw2COLOR_TURF_POLICE);
                                    }
                                    default: {
                                        
PlayerTextDrawShow(targetidTextdraw_None);
                                        
PlayerTextDrawBoxColor(targetid,Textdraw1COLOR_TURF_NONE);
                                        
PlayerTextDrawBoxColor(targetid,Textdraw2COLOR_TURF_NONE);
                                    }
                                }            
                                
PlayerTextDrawShow(targetidTextdraw0);
                                
PlayerTextDrawShow(targetidTextdraw1);
                                
PlayerTextDrawShow(targetidTextdraw2);
                                
PlayerTextDrawShow(targetidTextdraw3);
                                
PlayerTextDrawShow(targetidTextdraw4);
                                
PlayerTextDrawShow(targetidTextdraw5);
                                
PlayerTextDrawShow(targetidTextdraw6);
                                if(
Turfs[zid][Type] == 1)
                                    
PlayerTextDrawShow(targetidTextdraw8);
                                else
                                    
PlayerTextDrawShow(targetidTextdraw7);
                                
PlayerTextDrawSetString(targetidTextdraw3Turfs[zid][Street]);
                            }
                        }
                        switch(
GetPlayerTeam(Turfs[zid][Capturer])) {
                            case 
TEAM_GROVEGangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_GROVE0x000000FF);
                            case 
TEAM_BALLASGangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_BALLAS0x000000FF);
                            case 
TEAM_VAGOSGangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_VAGOS0x000000FF);
                            case 
TEAM_AZTECASGangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_AZTECAS0x000000FF);
                            case 
TEAM_BIKERSGangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_BIKERS0x000000FF);
                            case 
TEAM_SHERIFFGangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_SHERIFF0x000000FF);
                            case 
TEAM_POLICEGangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_POLICE0x000000FF);
                        }
                        new 
handle SQL::Open(SQL::UPDATE"turfs""id"zid); 
                        
SQL::WriteInt(handle"owner"team); 
                        
SQL::Close(handle);
                        break;
                    }
                }
            }
            else
                
SendClientMessage(playeridCOLOR_ERROR"You're not in any turf.");
        }
        else
            
SendClientMessage(playeridCOLOR_ERROR"USAGE: /setownedturf [team]");
    }
    else
        
SendClientMessage(playeridCOLOR_ERROR"You're not authorized to use this command.");

I am really confused about this, it's weird that even the default turf doesn't show up.
And to show the turfs for the player;
PHP код:
hook OnPlayerConnect(playerid) {
    for(new 
zid 0zid MAX_TURFSzid++) {
        if(
SQL::RowExists("turfs""id"zid)) {
            switch(
Turfs[zid][Owner]) {
                case 
TEAM_GROVEGangZoneShowForPlayer(playeridTurfs[zid][ID], COLOR_TURF_GROVE);
                case 
TEAM_BALLASGangZoneShowForPlayer(playeridTurfs[zid][ID], COLOR_TURF_BALLAS);
                case 
TEAM_VAGOSGangZoneShowForPlayer(playeridTurfs[zid][ID], COLOR_TURF_VAGOS);
                case 
TEAM_AZTECASGangZoneShowForPlayer(playeridTurfs[zid][ID], COLOR_TURF_AZTECAS);
                case 
TEAM_BIKERSGangZoneShowForPlayer(playeridTurfs[zid][ID], COLOR_TURF_BIKERS);
                case 
TEAM_SHERIFFGangZoneShowForPlayer(playeridTurfs[zid][ID], COLOR_TURF_SHERIFF);
                case 
TEAM_POLICEGangZoneShowForPlayer(playeridTurfs[zid][ID], COLOR_TURF_POLICE);
            }
        }
    }

Removed the textdraw codes.

Anyone have a clue?

Edit;
Before and after /setownedturf
http://imgur.com/a/x8xWs


Re: Gang zones, don't show for a player who just logged in. - Luicy. - 02.08.2016

Fixed.