forward OneSecTimer();
public OneSecTimer()
{
if(color1[playerid] == COLORNAME) // this is a player variable so u create it like this "new color1[MAX_PLAYERS];"
{
SetPlayerColor(playerid, COLOR CODE);
color1[playerid] = WHITECOLOR;
}
// and if u want lets say multiple colors do smth like this
else if(color1[playerid] == WHITECOLOR)
{
SetPlayerColor(playerid, BLack);
color1[playerid] = BLACKCOLOR;
}
return 1;
}
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(playerid, COLOR_BLACK);
colorchanged[playerid] = COLOR_WHITE;
}
else if(colorchanged[playerid] == COLOR_WHITE)
{
SetPlayerColor(playerid, COLOR_BLACK);
colorchanged[playerid] = COLOR_WHITE;
}
return 1;
}
//I've added this timer into the command
SetTimerEx("OneSecTimer", 100, true, "i", ID);
Ok look I've created it like this
PHP код:
|
SetTimerEx("OneSecTimer", 1000, true, "i", playerid);
forward OneSecTimer(playerid);
public OneSecTimer(playerid)
{
switch(colorchanged[playerid])
{
case COLOR_BLACK:
{
SetPlayerColor(playerid, COLOR_WHITE);
colorchanged[playerid] = COLOR_WHITE;
}
case COLOR_WHITE:
{
SetPlayerColor(playerid, COLOR_BLACK);
colorchanged[playerid] = COLOR_BLACK;
}
}
return 1;
}
if(CivilianTeam(GetPlayerSkin(ID)) || CIA(GetPlayerSkin(ID)))
{
SetTimerEx("OneSecTimer", 1000, true, "i", ID);
colorchanged[ID] = COLOR_WHITE;
return 1;
}
else if(SWAT(GetPlayerSkin(ID)))
{
SetTimerEx("OneSecTimer", 1000, true, "i", ID);
colorchanged[ID] = COLOR_LIGHTBLUE;
return 1;
}
else if(ArmyTeam(GetPlayerSkin(ID)))
{
SetTimerEx("OneSecTimer", 1000, true, "i", ID);
colorchanged[ID] = COLOR_PURPLE;
return 1;
}
else if(PoliceTeam(GetPlayerSkin(ID)) || FBII(GetPlayerSkin(ID)))
{
SetTimerEx("OneSecTimer", 1000, true, "i", ID);
colorchanged[ID] = 0x0080FFFF;
return 1;
}
forward OneSecTimer(playerid);
public OneSecTimer(playerid)
{
if(!CivilianTeam(GetPlayerSkin(playerid)) || !CIA(GetPlayerSkin(playerid)))
{
switch(colorchanged[playerid])
{
case COLOR_BLACK:
{
SetPlayerColor(playerid, COLOR_WHITE);
colorchanged[playerid] = COLOR_WHITE;
}
case COLOR_WHITE:
{
SetPlayerColor(playerid, COLOR_BLACK);
colorchanged[playerid] = COLOR_BLACK;
}
}
if(!PoliceTeam(GetPlayerSkin(playerid)) || !FBII(GetPlayerSkin(playerid)))
{
switch(colorchanged[playerid])
{
case COLOR_BLACK:
{
SetPlayerColor(playerid, 0x0080FFFF);
colorchanged[playerid] = 0x0080FFFF;
}
case COLOR_BLUE:
{
SetPlayerColor(playerid, COLOR_BLACK);
colorchanged[playerid] = COLOR_BLACK;
}
}
if(!ArmyTeam(GetPlayerSkin(playerid)))
{
switch(colorchanged[playerid])
{
case COLOR_BLACK:
{
SetPlayerColor(playerid, COLOR_PURPLE);
colorchanged[playerid] = COLOR_PURPLE;
}
case COLOR_PURPLE:
{
SetPlayerColor(playerid, COLOR_BLACK);
colorchanged[playerid] = COLOR_BLACK;
}
}
if(!SWAT(GetPlayerSkin(playerid)))
{
switch(colorchanged[playerid])
{
case COLOR_BLACK:
{
SetPlayerColor(playerid, COLOR_LIGHTBLUE);
colorchanged[playerid] = COLOR_LIGHTBLUE;
}
case COLOR_LIGHTBLUE:
{
SetPlayerColor(playerid, COLOR_BLACK);
colorchanged[playerid] = COLOR_BLACK;
}
}
}
}
}
}
return 1;
}
//In the HIT command add this:
else if(SWAT(GetPlayerSkin(ID)))
{
SetTimerEx("SWATCOLOR", 1000, true, "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(playerid, COLOR_LIGHTBLUE);
colorchanged[playerid] = COLOR_LIGHTBLUE;
}
case COLOR_LIGHTBLUE:
{
SetPlayerColor(playerid, COLOR_BLACK);
colorchanged[playerid] = COLOR_BLACK;
}
}
return 1;
}
//NOTE: Do this and it will be worked! I hope you understand..
@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!
|
#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(playerid, params[])
{
gTeam[playerid] = TEAM_SWAT; // player\'s team will == TEAM_SWAT
return 1;
}
CMD:killallswat(playerid, params[])
{
for(new i; i < MAX_PLAYERS; i++) // loop all players
{
if(gTeam[i] == TEAM_SWAT) // if player\'d id == TEAM_SWAT
{
SetPlayerHealth(i, 0);
}
}
return 1;
}
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.
|
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 |