Player color changed every secdon!
#1

How to I can make player color changed every 1second? Example: Player color_white every 1secdons color must be COLOR_BLACK! Do you got it? Like Examples: Player Color was WHITE AFTER SECDONS Must be black and auto changed from black to white! How to do that?
Reply
#2

Well u create an timer that ticks every 1 second, if u want "random" colors like if your last was white u set it to black then u create variables, and take that 1 sec timer and put smth like this in there

PHP код:
forward OneSecTimer();
public 
OneSecTimer()
{
if(
color1[playerid] == COLORNAME// this is a player variable so u create it like this "new color1[MAX_PLAYERS];" 
{
SetPlayerColor(playeridCOLOR CODE);
color1[playerid] = WHITECOLOR;
}
// and if u want lets say multiple colors do smth like this
else if(color1[playerid] == WHITECOLOR)
{
SetPlayerColor(playeridBLack);
color1[playerid] = BLACKCOLOR;
}
return 
1;

Reply
#3

Ok look I've created it like this

PHP код:
forward OneSecTimer(playerid);
public 
OneSecTimer(playerid)
{
    if(
colorchanged[playerid] == COLOR_WHITE// this is a player variable so u create it like this "new color1[MAX_PLAYERS];"
    
{
        
SetPlayerColor(playeridCOLOR_BLACK);
        
colorchanged[playerid] = COLOR_WHITE;
    }
    else if(
colorchanged[playerid] == COLOR_WHITE)
    {
        
SetPlayerColor(playeridCOLOR_BLACK);
        
colorchanged[playerid] = COLOR_WHITE;
    }
    return 
1;
}
//I've added this timer into the command
SetTimerEx("OneSecTimer"100true"i"ID); 
and not work why
Reply
#4

Quote:
Originally Posted by Man43
Посмотреть сообщение
Ok look I've created it like this

PHP код:
forward OneSecTimer(playerid);
public 
OneSecTimer(playerid)
{
    if(
colorchanged[playerid] == COLOR_WHITE)
    {
        
SetPlayerColor(playeridCOLOR_BLACK);
        
colorchanged[playerid] = COLOR_WHITE;
    }
    else if(
colorchanged[playerid] == COLOR_WHITE)
    {
        
SetPlayerColor(playeridCOLOR_BLACK);
        
colorchanged[playerid] = COLOR_WHITE;
    }
    return 
1;
}
//I've added this timer into the command
SetTimerEx("OneSecTimer"100true"i"ID); 
and not work why
Well that's not a one second, try like this
PHP код:
SetTimerEx("OneSecTimer"1000true"i"playerid); 
If that doesn't work show me the server_log ( crashdetect mybe )

EDIT: Add the player's color in that command ( colorchange[playerid] = WHITE_COLOR; )
Reply
#5

U can also improve the timer by doing the next thing

PHP код:
forward OneSecTimer(playerid);
public 
OneSecTimer(playerid)
{
switch(
colorchanged[playerid])
{
    case 
COLOR_BLACK:
    {
        
SetPlayerColor(playeridCOLOR_WHITE);
        
colorchanged[playerid] = COLOR_WHITE;
    }
    case 
COLOR_WHITE:
    {
        
SetPlayerColor(playeridCOLOR_BLACK);
        
colorchanged[playerid] = COLOR_BLACK;
    }
}
    return 
1;

Do it like that after u finish the system
Reply
#6

You're better off to use the tick timer as it should be used, and to not simply fire it up when it's needed for such a task as this... There's no doubt other systems you are using that are going to be using tick timers, or could be added to a tick timer to make it less wasteful.
Reply
#7

Thank you so much it's worked now +rep.
Reply
#8

Hey again bro! I'm trying to make a colors changed for other's skin but I got no errors / warrings but Color not changed why? It's just changed to Civillian's only..

PHP код:
if(CivilianTeam(GetPlayerSkin(ID)) || CIA(GetPlayerSkin(ID)))
                     {
                        
SetTimerEx("OneSecTimer"1000true"i"ID);
                        
colorchanged[ID] = COLOR_WHITE;
                        return 
1;
                    }
                    else if(
SWAT(GetPlayerSkin(ID)))
                    {
                        
SetTimerEx("OneSecTimer"1000true"i"ID);
                        
colorchanged[ID] = COLOR_LIGHTBLUE;
                        return 
1;
                    }
                    else if(
ArmyTeam(GetPlayerSkin(ID)))
                    {
                        
SetTimerEx("OneSecTimer"1000true"i"ID);
                        
colorchanged[ID] = COLOR_PURPLE;
                        return 
1;
                    }
                    else if(
PoliceTeam(GetPlayerSkin(ID)) || FBII(GetPlayerSkin(ID)))
                    {
                        
SetTimerEx("OneSecTimer"1000true"i"ID);
                        
colorchanged[ID] = 0x0080FFFF;
                        return 
1;
                    } 
PHP код:
forward OneSecTimer(playerid);
public 
OneSecTimer(playerid)
{
    if(!
CivilianTeam(GetPlayerSkin(playerid)) || !CIA(GetPlayerSkin(playerid)))
    {
        switch(
colorchanged[playerid])
        {
            case 
COLOR_BLACK:
            {
                
SetPlayerColor(playeridCOLOR_WHITE);
                
colorchanged[playerid] = COLOR_WHITE;
            }
            case 
COLOR_WHITE:
            {
                
SetPlayerColor(playeridCOLOR_BLACK);
                
colorchanged[playerid] = COLOR_BLACK;
            }
        }
    if(!
PoliceTeam(GetPlayerSkin(playerid)) || !FBII(GetPlayerSkin(playerid)))
    {
        switch(
colorchanged[playerid])
        {
            case 
COLOR_BLACK:
            {
                
SetPlayerColor(playerid0x0080FFFF);
                
colorchanged[playerid] = 0x0080FFFF;
            }
            case 
COLOR_BLUE:
            {
                
SetPlayerColor(playeridCOLOR_BLACK);
                
colorchanged[playerid] = COLOR_BLACK;
            }
        }
    if(!
ArmyTeam(GetPlayerSkin(playerid)))
    {
        switch(
colorchanged[playerid])
        {
            case 
COLOR_BLACK:
            {
                
SetPlayerColor(playeridCOLOR_PURPLE);
                
colorchanged[playerid] = COLOR_PURPLE;
            }
            case 
COLOR_PURPLE:
            {
                
SetPlayerColor(playeridCOLOR_BLACK);
                
colorchanged[playerid] = COLOR_BLACK;
            }
        }
    if(!
SWAT(GetPlayerSkin(playerid)))
    {
        switch(
colorchanged[playerid])
        {
            case 
COLOR_BLACK:
            {
                
SetPlayerColor(playeridCOLOR_LIGHTBLUE);
                
colorchanged[playerid] = COLOR_LIGHTBLUE;
            }
            case 
COLOR_LIGHTBLUE:
            {
                
SetPlayerColor(playeridCOLOR_BLACK);
                
colorchanged[playerid] = COLOR_BLACK;
            }
        }
    }
    }
    }
    }
    return 
1;

Reply
#9

And here again we see this skin checking for faction roles...... Why......
Reply
#10

@Sew_Sumi, IDK I think It's were faster & better! anyway I don't know how to TEAM_COP like this because the tutoirals are not understand me!

@SO HOW TO I CAN MAKE MULTI-COLORS CHANGED FOR EVERY SKIN? EXAMPLE: If the enemy player is swat skin and someone placed hit on him! his color must be " LIGHTBLUE AFTER 1SEC BLACK " How?
Reply
#11

I don\'t think your code will worked! but you are not defined them! So I hope If you following me like you did! To creating a more factions! In same point!

PHP Code:
//In the HIT command add this: 

else if(SWAT(GetPlayerSkin(ID)))
                    {
                        
SetTimerEx("SWATCOLOR"1000true"i"ID);
                        
colorchanged[ID] = COLOR_LIGHTBLUE;
                        return 
1;
                    }

//As you created a civilian and follow all skins by this Then

forward SWATCOLOR(playerid);
public 
SWATCOLOR(playerid)
{
    switch(
colorchanged[playerid])
    {
        case 
COLOR_BLACK:
         {
              
SetPlayerColor(playeridCOLOR_LIGHTBLUE);
            
colorchanged[playerid] = COLOR_LIGHTBLUE;
        }
         case 
COLOR_LIGHTBLUE:
          {
               
SetPlayerColor(playeridCOLOR_BLACK);
            
colorchanged[playerid] = COLOR_BLACK;
          }
    }
    return 
1;
}

//NOTE: Do this and it will be worked! I hope you understand.. 
Reply
#12

Quote:
Originally Posted by Man43
View Post
@Sew_Sumi, IDK I think It\'s were faster & better! anyway I don\'t know how to TEAM_COP like this because the tutoirals are not understand me!
It\'s a lot more simple to fuck over your server by simply skin hacking your skin, and shitting all over your playerbase because your script was so shit that it wasn\'t tracking teams, just skins...




Seriously, this is TERRIBLE FUCKING PRACTICE.........
Reply
#13

I agree with Sew_Sumi. As SA-MP has increased in it\'s popularity, there have been many more cheats introducted in this game. The player could somehow change their skin and spoof themselves into being another team.


You should try assigning the players to a global array of each team stored.


For example:

PHP Code:
#include <a_samp>

#define TEAM_SWAT 1
#define TEAM_POLICE 2
#define TEAM_ROBBER 3


new gTeam[MAX_PLAYERS]; // player team = gTeam[TEAM_SWAT] which will decode to player team = gTeam[1] (for swat)

CMD:teamswat(playeridparams[])
{
    
gTeam[playerid] = TEAM_SWAT// player\'s team will == TEAM_SWAT

    
return 1;
}


CMD:killallswat(playeridparams[])
{
    for(new 
iMAX_PLAYERSi++) // loop all players
    
{
        if(
gTeam[i] == TEAM_SWAT// if player\'d id == TEAM_SWAT
        
{
            
SetPlayerHealth(i0);
        }
    }

    return 
1;

This is an example how you can use them method rather than checking for skins to depict the player\'s team.
Reply
#14

Ok I agree with you guys but!! How to defined Them? Example: TEAM_SWAT you are not choosing what is team_swat and for what skins? Right? I\'m sorry but I don\'t understand this teams yet! Because you did TEAM_SWAT How do we know that this IS FOR SKIN ID285? Can you explain?


@Sew_Sumi + @brauf
Reply
#15

Quote:
Originally Posted by Sew_Sumi
View Post
You\'re better off to use the tick timer as it should be used, and to not simply fire it up when it\'s needed for such a task as this... There\'s no doubt other systems you are using that are going to be using tick timers, or could be added to a tick timer to make it less wasteful.
That\'s the exact opposite of what you should be doing! Start a new timer.
Reply
#16

Quote:
Originally Posted by Man43
View Post
Ok I agree with you guys but!! How to defined Them? Example: TEAM_SWAT you are not choosing what is team_swat and for what skins? Right? I\'m sorry but I don\'t understand this teams yet! Because you did TEAM_SWAT How do we know that this IS FOR SKIN ID285? Can you explain?


@Sew_Sumi + @brauf
You use a gTeam array, and make that track which team the players are in. There should be a few tutorials pop up for team information when you search for gTeam.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)