SA-MP Forums Archive
player's color (again :v) - 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: player's color (again :v) (/showthread.php?tid=513770)



player's color (again :v) - AiRaLoKa - 18.05.2014

hi all...

i got one question....
why is my player's color turned into black when they are died?


Re: player's color (again :v) - Threshold - 18.05.2014

I got one question...

How can we fix it without seeing the code?
Please show us your OnPlayerDeath. I would assume you are doing something like:
pawn Код:
SetPlayerColor(playerid, GetPlayerColor(playerid));
without actually setting a player color first.


Re: player's color (again :v) - Dignity - 18.05.2014

Can you show us your

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
contents?


Re: player's color (again :v) - AiRaLoKa - 18.05.2014

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    LoadColor(playerid);
    return 1;
}
pawn Код:
stock LoadColor(playerid)
{
if(pInfo[playerid][pUseCol] == 1)
        {
            /*new color;
            //strmid(color,pInfo[playerid][pColor], 0, strlen(pInfo[playerid][pColor]), 11);
            color = pInfo[playerid][pColor];
            color <<= 8;
            color |= 0xFF;*/

            SetPlayerColor(playerid, pInfo[playerid][pColor]);
        }
        if(pInfo[playerid][pUseCol] == 0)
        {
            SetPlayerColor(playerid, PlayerColors[playerid]);
        }
}



Re: player's color (again :v) - RajatPawar - 18.05.2014

Add prints to see what "PlayerColors[playerid]" is actually during the execution of that callback. Print out ALL the stuff, and I'm sure you'll see the problem!


Re: player's color (again :v) - AiRaLoKa - 18.05.2014

no the problem is only at these line....

pawn Код:
if(pInfo[playerid][pUseCol] == 1)
        {
            /*new color;
            //strmid(color,pInfo[playerid][pColor], 0, strlen(pInfo[playerid][pColor]), 11);
            color = pInfo[playerid][pColor];
            color <<= 8;
            color |= 0xFF;*/

            SetPlayerColor(playerid, pInfo[playerid][pColor]);
        }
but it's just okay when it's called on MySQL_Login


Re: player's color (again :v) - Threshold - 18.05.2014

pInfo[playerid][pColor] is the wrong value.

Do this:
pawn Код:
if(pInfo[playerid][pUseCol] == 1)
        {
            /*new color;
            //strmid(color,pInfo[playerid][pColor], 0, strlen(pInfo[playerid][pColor]), 11);
            color = pInfo[playerid][pColor];
            color <<= 8;
            color |= 0xFF;*/

            SetPlayerColor(playerid, pInfo[playerid][pColor]);
            printf("%d", pInfo[playerid][pColor]);
        }
Then see what appears in your server log/console.

EDIT: You can also shorten your code to:

pawn Код:
stock LoadColor(playerid)
    return SetPlayerColor(playerid, ((pInfo[playerid][pUseCol]) ? (pInfo[playerid][pColor]) : (PlayerColors[playerid])));



Re: player's color (again :v) - AiRaLoKa - 18.05.2014

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
pInfo[playerid][pColor] is the wrong value.

Do this:
pawn Код:
if(pInfo[playerid][pUseCol] == 1)
        {
            /*new color;
            //strmid(color,pInfo[playerid][pColor], 0, strlen(pInfo[playerid][pColor]), 11);
            color = pInfo[playerid][pColor];
            color <<= 8;
            color |= 0xFF;*/

            SetPlayerColor(playerid, pInfo[playerid][pColor]);
            printf("%d", pInfo[playerid][pColor]);
        }
Then see what appears in your server log/console.

EDIT: You can also shorten your code to:

pawn Код:
stock LoadColor(playerid)
    return SetPlayerColor(playerid, ((pInfo[playerid][pUseCol]) ? (pInfo[playerid][pColor]) : (PlayerColors[playerid])));
i will try it...

EDIT:

i've edited my LoadColor into
pawn Код:
stock LoadColor(playerid,onlogin)
{
    if(onlogin == 1) return SetPlayerColor(playerid, ((pInfo[playerid][pUseCol]) ? (pInfo[playerid][pColor]) : (PlayerColors[playerid]))), printf("%d", pInfo[playerid][pColor]);
    return 1;
}
and change the LoadColor at OnPlayerDeath into
pawn Код:
LoadColor(playerid, 0);