color loaded from mysql -
elcid7772 - 25.10.2010
So I'm trying to create gangzones that can be fought for by rival gangs, (This means the color will change a lot, more than likely). So I have it set save/load the zone's with mysql.
pawn Код:
stock CreateGangZone(Float:MinX,Float:MinY,Float:MaxX,Float:MaxY)
{
gzcount ++;
new GZ = gzcount, query[120], row[100], field[3][50];
GA[GZ] = CreateDynamicRectangle(MinX,MinY,MaxX,MaxY,-1,-1,-1);
GC[GZ] = GangZoneCreate(MinX,MinY,MaxX,MaxY);
format(query,sizeof(query), "SELECT * FROM `gangzones` WHERE `zoneID`='%d'",GZ);
mysql_check();
mysql_query(query);
mysql_store_result();
if(mysql_num_rows()) {
mysql_fetch_row(row, "|");
explode(row, field, "|");
format(zData[GZ][controler],50, "%s", field[0]);
format(zData[GZ][color],25,"0x%s99",field[2]);
mysql_free_result();
} else {
format(query,sizeof(query), "INSERT INTO `gangzones` (`controler`,`zoneID`,zonecolor) VALUES ('Unclaimed Territory','%d','2B2B2B')",GZ);
format(zData[GZ][controler], 50, "Unclaimed Territory");
format(zData[GZ][color], 25, "0x2B2B2B99");
mysql_check();
mysql_query(query);
mysql_free_result();
}
}
public OnPlayerSpawn(playerid)
{
for(new x;x<MAX_ZONES;x++) {
GangZoneShowForPlayer(playerid, GC[x], zData[x][color]);
}
return 1;
}
For some reason, the zones show, but they are not the color that they should be(default color being 2B2B2B). Instead they are this VERY faint greyish color, and you won't even see it unless you are concentrating on the map
Re: color loaded from mysql -
DVDK - 25.10.2010
I've tryed this many times before and always failed, i guess it's imposible since there's no way to convert a string into a hex code.
When you use format to convert your string from MySQL to a variable inside your script, it deleted the x from 0x000000FF and you will get a messed up code.
Re: color loaded from mysql -
elcid7772 - 25.10.2010
Quote:
Originally Posted by DVDK
I've tryed this many times before and always failed, i guess it's imposible since there's no way to convert a string into a hex code.
When you use format to convert your string from MySQL to a variable inside your script, it deleted the x from 0x000000FF and you will get a messed up code.
|
I find it hard to believe that this is impossible.
Re: color loaded from mysql -
DarrenReeder - 25.10.2010
Tried this before.. couldnt work out solution..
I ended up just making colors scripted (useing COLOR_1 or COLOR_GANGNAME constants).. gdluck with this
Re: color loaded from mysql -
Lookin - 26.10.2010
mmm im not sure ill look into it for ya maybe ****** or Ryder have the answer
Re: color loaded from mysql -
elcid7772 - 26.10.2010
Bu-bump.
Re: color loaded from mysql -
DVDK - 26.10.2010
Quote:
Originally Posted by DarrenReeder
Tried this before.. couldnt work out solution..
I ended up just making colors scripted (useing COLOR_1 or COLOR_GANGNAME constants).. gdluck with this
|
I did the same thing, don't think there really is a solution for this.
Re: color loaded from mysql -
Cameltoe - 26.10.2010
https://sampwiki.blast.hk/wiki/Format
https://sampwiki.blast.hk/wiki/Hex
EDIT: while trying with some of the implemented functions, i failed.. i think you need an plugin to make something like this. I might be wrong on this...
What you could do as an workaround:
pawn Код:
new FetchedColor = 1; // pretend i did fetch this from an db.
if(FetchedColor == 1) //CreateTurf with the color 1. Color 1 = COLOR_RED.
else if(FetchedColor == 2) //CreateTurf with the color 2. Color 2 = COLOR_BLUE.
// ETC...
Re: color loaded from mysql -
elcid7772 - 27.10.2010
Quote:
Originally Posted by Cameltoe
https://sampwiki.blast.hk/wiki/Format
https://sampwiki.blast.hk/wiki/Hex
EDIT: while trying with some of the implemented functions, i failed.. i think you need an plugin to make something like this. I might be wrong on this...
What you could do as an workaround:
pawn Код:
new FetchedColor = 1; // pretend i did fetch this from an db.
if(FetchedColor == 1) //CreateTurf with the color 1. Color 1 = COLOR_RED. else if(FetchedColor == 2) //CreateTurf with the color 2. Color 2 = COLOR_BLUE. // ETC...
|
Ya that's basically what I ended up doing. Thx for trying anyway.