color loaded from mysql
#1

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
Reply
#2

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.
Reply
#3

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.
Reply
#4

Tried this before.. couldnt work out solution..

I ended up just making colors scripted (useing COLOR_1 or COLOR_GANGNAME constants).. gdluck with this
Reply
#5

mmm im not sure ill look into it for ya maybe ****** or Ryder have the answer
Reply
#6

Bu-bump.
Reply
#7

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.
Reply
#8

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...
Reply
#9

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)