player's color (again :v)
#1

hi all...

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

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

Can you show us your

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

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]);
        }
}
Reply
#5

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!
Reply
#6

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

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])));
Reply
#8

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);
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)