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 = 0; zid < MAX_TURFS; zid++) {
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_GROVE: Turfs[zid][ID] = GangZoneCreate(Turfs[zid][MinX], Turfs[zid][MinY], Turfs[zid][MaxX], Turfs[zid][MaxY], COLOR_TURF_GROVE, 0, 0, 1.5, 0x000000FF);
case TEAM_BALLAS: Turfs[zid][ID] = GangZoneCreate(Turfs[zid][MinX], Turfs[zid][MinY], Turfs[zid][MaxX], Turfs[zid][MaxY], COLOR_TURF_BALLAS, 0, 0, 1.5, 0x000000FF);
case TEAM_VAGOS: Turfs[zid][ID] = GangZoneCreate(Turfs[zid][MinX], Turfs[zid][MinY], Turfs[zid][MaxX], Turfs[zid][MaxY], COLOR_TURF_VAGOS, 0, 0, 1.5, 0x000000FF);
case TEAM_AZTECAS: Turfs[zid][ID] = GangZoneCreate(Turfs[zid][MinX], Turfs[zid][MinY], Turfs[zid][MaxX], Turfs[zid][MaxY], COLOR_TURF_AZTECAS, 0, 0, 1.5, 0x000000FF);
case TEAM_BIKERS: Turfs[zid][ID] = GangZoneCreate(Turfs[zid][MinX], Turfs[zid][MinY], Turfs[zid][MaxX], Turfs[zid][MaxY], COLOR_TURF_BIKERS, 0, 0, 1.5, 0x000000FF);
case TEAM_SHERIFF: Turfs[zid][ID] = GangZoneCreate(Turfs[zid][MinX], Turfs[zid][MinY], Turfs[zid][MaxX], Turfs[zid][MaxY], COLOR_TURF_SHERIFF, 0, 0, 1.5, 0x000000FF);
case TEAM_POLICE: Turfs[zid][ID] = GangZoneCreate(Turfs[zid][MinX], Turfs[zid][MinY], Turfs[zid][MaxX], Turfs[zid][MaxY], COLOR_TURF_POLICE, 0, 0, 1.5, 0x000000FF);
default: Turfs[zid][ID] = GangZoneCreate(Turfs[zid][MinX], Turfs[zid][MinY], Turfs[zid][MaxX], Turfs[zid][MaxY], COLOR_TURF_NONE, 0, 0, 1.5, 0x000000FF);
}
}
}
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(playerid, params[]) {
if(Account[playerid][Staff] > 4) {
new team;
if(!sscanf(params, "i", team)) {
if(IsPlayerInAnyGangZone(playerid)) {
for(new zid = 0; zid < MAX_TURFS; zid++) {
if(SQL::RowExists("turfs", "id", zid) && IsPlayerInGangZone(playerid, Turfs[zid][ID])) {
new string[128];
format(string, 128, "Admin %s forced turf %s to be owned by %s.", GetName(playerid), Turfs[zid][Street], GetTeamName(team));
SendClientMessageToAll(COLOR_DEF, string);
Teams[Turfs[zid][Owner]][Turf]--;
Teams[team][Turf]++;
Turfs[zid][Owner] = team;
switch(team) {
case TEAM_GROVE: GangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_GROVE);
case TEAM_BALLAS: GangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_BALLAS);
case TEAM_VAGOS: GangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_VAGOS);
case TEAM_AZTECAS: GangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_AZTECAS);
case TEAM_BIKERS: GangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_BIKERS);
case TEAM_SHERIFF: GangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_SHERIFF);
case TEAM_POLICE: GangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_POLICE);
}
for(new targetid = 0; targetid < MAX_PLAYERS; targetid++) {
if(IsPlayerConnected(targetid) && IsPlayerInGangZone(targetid, Turfs[zid][ID])) {
PlayerTextDrawHide(targetid, Textdraw0);
PlayerTextDrawHide(targetid, Textdraw1);
PlayerTextDrawHide(targetid, Textdraw2);
PlayerTextDrawHide(targetid, Textdraw3);
PlayerTextDrawHide(targetid, Textdraw4);
PlayerTextDrawHide(targetid, Textdraw5);
PlayerTextDrawHide(targetid, Textdraw6);
PlayerTextDrawHide(targetid, Textdraw7);
PlayerTextDrawHide(targetid, Textdraw8);
PlayerTextDrawHide(targetid, Textdraw_Grove);
PlayerTextDrawHide(targetid, Textdraw_Ballas);
PlayerTextDrawHide(targetid, Textdraw_Vagos);
PlayerTextDrawHide(targetid, Textdraw_Aztecas);
PlayerTextDrawHide(targetid, Textdraw_Bikers);
PlayerTextDrawHide(targetid, Textdraw_Sheriff);
PlayerTextDrawHide(targetid, Textdraw_Police);
PlayerTextDrawHide(targetid, Textdraw_None);
switch(Turfs[zid][Owner]) {
case TEAM_GROVE: {
PlayerTextDrawShow(targetid, Textdraw_Grove);
PlayerTextDrawBoxColor(targetid,Textdraw1, COLOR_TURF_GROVE);
PlayerTextDrawBoxColor(targetid,Textdraw2, COLOR_TURF_GROVE);
}
case TEAM_BALLAS: {
PlayerTextDrawShow(targetid, Textdraw_Ballas);
PlayerTextDrawBoxColor(targetid,Textdraw1, COLOR_TURF_BALLAS);
PlayerTextDrawBoxColor(targetid,Textdraw2, COLOR_TURF_BALLAS);
}
case TEAM_VAGOS: {
PlayerTextDrawShow(targetid, Textdraw_Vagos);
PlayerTextDrawBoxColor(targetid,Textdraw1, COLOR_TURF_VAGOS);
PlayerTextDrawBoxColor(targetid,Textdraw2, COLOR_TURF_VAGOS);
}
case TEAM_AZTECAS: {
PlayerTextDrawShow(targetid, Textdraw_Aztecas);
PlayerTextDrawBoxColor(targetid,Textdraw1, COLOR_TURF_AZTECAS);
PlayerTextDrawBoxColor(targetid,Textdraw2, COLOR_TURF_AZTECAS);
}
case TEAM_BIKERS: {
PlayerTextDrawShow(targetid, Textdraw_Bikers);
PlayerTextDrawBoxColor(targetid,Textdraw1, COLOR_TURF_BIKERS);
PlayerTextDrawBoxColor(targetid,Textdraw2, COLOR_TURF_BIKERS);
}
case TEAM_SHERIFF: {
PlayerTextDrawShow(targetid, Textdraw_Sheriff);
PlayerTextDrawBoxColor(targetid,Textdraw1, COLOR_TURF_SHERIFF);
PlayerTextDrawBoxColor(targetid,Textdraw2, COLOR_TURF_SHERIFF);
}
case TEAM_POLICE: {
PlayerTextDrawShow(targetid, Textdraw_Police);
PlayerTextDrawBoxColor(targetid,Textdraw1, COLOR_TURF_POLICE);
PlayerTextDrawBoxColor(targetid,Textdraw2, COLOR_TURF_POLICE);
}
default: {
PlayerTextDrawShow(targetid, Textdraw_None);
PlayerTextDrawBoxColor(targetid,Textdraw1, COLOR_TURF_NONE);
PlayerTextDrawBoxColor(targetid,Textdraw2, COLOR_TURF_NONE);
}
}
PlayerTextDrawShow(targetid, Textdraw0);
PlayerTextDrawShow(targetid, Textdraw1);
PlayerTextDrawShow(targetid, Textdraw2);
PlayerTextDrawShow(targetid, Textdraw3);
PlayerTextDrawShow(targetid, Textdraw4);
PlayerTextDrawShow(targetid, Textdraw5);
PlayerTextDrawShow(targetid, Textdraw6);
if(Turfs[zid][Type] == 1)
PlayerTextDrawShow(targetid, Textdraw8);
else
PlayerTextDrawShow(targetid, Textdraw7);
PlayerTextDrawSetString(targetid, Textdraw3, Turfs[zid][Street]);
}
}
switch(GetPlayerTeam(Turfs[zid][Capturer])) {
case TEAM_GROVE: GangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_GROVE, 0x000000FF);
case TEAM_BALLAS: GangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_BALLAS, 0x000000FF);
case TEAM_VAGOS: GangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_VAGOS, 0x000000FF);
case TEAM_AZTECAS: GangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_AZTECAS, 0x000000FF);
case TEAM_BIKERS: GangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_BIKERS, 0x000000FF);
case TEAM_SHERIFF: GangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_SHERIFF, 0x000000FF);
case TEAM_POLICE: GangZoneSetColorForAll(Turfs[zid][ID], COLOR_TURF_POLICE, 0x000000FF);
}
new handle = SQL::Open(SQL::UPDATE, "turfs", "id", zid);
SQL::WriteInt(handle, "owner", team);
SQL::Close(handle);
break;
}
}
}
else
SendClientMessage(playerid, COLOR_ERROR, "You're not in any turf.");
}
else
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /setownedturf [team]");
}
else
SendClientMessage(playerid, COLOR_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 = 0; zid < MAX_TURFS; zid++) {
if(SQL::RowExists("turfs", "id", zid)) {
switch(Turfs[zid][Owner]) {
case TEAM_GROVE: GangZoneShowForPlayer(playerid, Turfs[zid][ID], COLOR_TURF_GROVE);
case TEAM_BALLAS: GangZoneShowForPlayer(playerid, Turfs[zid][ID], COLOR_TURF_BALLAS);
case TEAM_VAGOS: GangZoneShowForPlayer(playerid, Turfs[zid][ID], COLOR_TURF_VAGOS);
case TEAM_AZTECAS: GangZoneShowForPlayer(playerid, Turfs[zid][ID], COLOR_TURF_AZTECAS);
case TEAM_BIKERS: GangZoneShowForPlayer(playerid, Turfs[zid][ID], COLOR_TURF_BIKERS);
case TEAM_SHERIFF: GangZoneShowForPlayer(playerid, Turfs[zid][ID], COLOR_TURF_SHERIFF);
case TEAM_POLICE: GangZoneShowForPlayer(playerid, Turfs[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.