SetPlayerColor does not work... wtf? -
knackworst - 30.08.2011
hi,
I have a lil problem with setplayercolor or gTeam[playerid] I don't really know where the problem is...
anyways so I made a map, where you spawn from there you can chose your class by picking up pickups...
the code:
pawn Код:
if(pickupid == banditpickupspawn)
{
SetPlayerPos(playerid, 696.0515,-1444.0397,13.5391);
gTeam[playerid] = TEAM_BANDIT;
SetPlayerColor(playerid,COLOR_ORANGE); // orange
new name[MAX_PLAYER_NAME], string[44];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s Joined team Bandits!",name);
SendClientMessageToAllBandits(string);
SendClientMessage(playerid, COLOR_YELLOW, "Welcome in team Bandits! use * for a teamchat about bandits: /bandits");
if(IsLevel1[playerid] == 1)
{
SetPlayerHealth(playerid, 100);
SetPlayerSkin(playerid,BandSkinsL1[random(sizeof(BandSkinsL1))]);
GivePlayerWeapon(playerid, 30, 200); //slot 5
GivePlayerWeapon(playerid, 28, 500); //slot 4
GivePlayerWeapon(playerid, 24, 20); //slot 2
GivePlayerWeapon(playerid, 1, 0); //slot 2
GameTextForPlayer(playerid, "~w~ Joined Team Bandits! (/bandits) (LVL 1___/l1)", 3000, 4);
}
if(IsLevel2[playerid] == 1)
{
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 50);
SetPlayerSkin(playerid,BandSkinsL2[random(sizeof(BandSkinsL2))]);
GivePlayerWeapon(playerid, 30, 400); //slot 5
GivePlayerWeapon(playerid, 28, 1000); //slot 4
GivePlayerWeapon(playerid, 24, 40); //slot 2
GivePlayerWeapon(playerid, 26, 50); //slot 3
GameTextForPlayer(playerid, "~w~ Joined Team Bandits! (/bandits) (LVL 2___/l2)", 3000, 4);
}
if(IsLevel3[playerid] == 1)
{
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
SetPlayerSkin(playerid,BandSkinsL3[random(sizeof(BandSkinsL3))]);
GivePlayerWeapon(playerid, 30, 800); //slot 5
GivePlayerWeapon(playerid, 28, 2000); //slot 4
GivePlayerWeapon(playerid, 24, 80); //slot 2
GivePlayerWeapon(playerid, 26, 100); //slot 3
GivePlayerWeapon(playerid, 18, 20); //slot 8
GameTextForPlayer(playerid, "~w~ Joined Team Bandits! (/bandits) (LVL 3___/l3)", 3000, 4);
}
}
//==============================================================================
//COPS Spawn
//==============================================================================
if(pickupid == coppickupspawn)
{
SetPlayerPos(playerid, 1580.4596,-1634.8533,13.5612);
gTeam[playerid] = TEAM_COPS;
SetPlayerColor(playerid,COLOR_ROYALBLUE); // blue
new name[MAX_PLAYER_NAME], string[44];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s Joined team Cops!",name);
SendClientMessageToAllCops(string);
if(IsLevel1[playerid] == 1)
{
GivePlayerWeapon(playerid, 23, 20); //slot 2
GivePlayerWeapon(playerid, 17, 1000); //slot 8
SendClientMessage(playerid, COLOR_YELLOW, "Welcome in team cops! use * for a teamchat NOTE: the silenced is a Tazer and the spray is tear gass more about cops: /cops");
SendClientMessage(playerid, COLOR_YELLOW, "Your weapons: Teargas Tazer");
SendClientMessage(playerid, COLOR_YELLOW, "Your level: 1 (Cop)");
SetPlayerHealth(playerid, 100);
SetPlayerSkin(playerid,CopSkinsL1[random(sizeof(CopSkinsL1))]);
GameTextForPlayer(playerid, "~w~ Joined Team Cops! (/cops) (LVL 1___/l1)", 3000, 4);
}
if(IsLevel2[playerid] == 1)
{
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 50);
SetPlayerSkin(playerid,CopSkinsL2[random(sizeof(CopSkinsL2))]);
GivePlayerWeapon(playerid, 23, 40); //slot 2
GivePlayerWeapon(playerid, 17, 2000); //slot 4
GivePlayerWeapon(playerid, 29, 200); //slot 8
SendClientMessage(playerid, COLOR_YELLOW, "Welcome in team cops! use * for a teamchat NOTE: the silenced is a Tazer and the spray is tear gass more about cops: /cops");
SendClientMessage(playerid, COLOR_YELLOW, "Your weapons: Teargas Tazer MP5");
SendClientMessage(playerid, COLOR_YELLOW, "Your level: 2 (S.W.A.T)");
GameTextForPlayer(playerid, "~w~ Joined Team Cops! (/cops) (LVL 2___/l2)", 3000, 4);
}
if(IsLevel3[playerid] == 1)
{
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
SetPlayerSkin(playerid,CopSkinsL3[random(sizeof(CopSkinsL3))]);
GivePlayerWeapon(playerid, 23, 80); //slot 2
GivePlayerWeapon(playerid, 17, 4000); //slot 8
GivePlayerWeapon(playerid, 29, 400); //slot 4
GivePlayerWeapon(playerid, 30, 400); //slot 5
GivePlayerWeapon(playerid, 34, 50); //slot 6
GivePlayerWeapon(playerid, 26, 200); //slot 3
SendClientMessage(playerid, COLOR_YELLOW, "Welcome in team cops! use * for a teamchat NOTE: the silenced is a Tazer and the spray is tear gass more about cops: /cops");
SendClientMessage(playerid, COLOR_YELLOW, "Your weapons: Teargas Tazer MP5 AK-47 Sniper_Rifle Sawn-off Shotgun");
SendClientMessage(playerid, COLOR_YELLOW, "Your level: 3 (FBI)");
GameTextForPlayer(playerid, "~w~ Joined Team Cops! (/cops) (LVL 3___/l3)", 3000, 4);
}
}
//==============================================================================
//Driver Spawn
//==============================================================================
if(pickupid == driverpickupspawn)
{
SetPlayerPos(playerid, 722.0700,-1276.4917,17.6484);
gTeam[playerid] = TEAM_DRIVERS;
SetPlayerColor(playerid,COLOR_SEXYGREEN); // green
new name[MAX_PLAYER_NAME], string[44];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s Joined team Drivers!",name);
SendClientMessageToAllDrivers(string);
//gTeam[playerid] = 0;
if(IsLevel1[playerid] == 1)
{
SetPlayerHealth(playerid, 100);
GivePlayerWeapon(playerid, 22, 10); //slot 2
SetPlayerSkin(playerid,DrivSkinsL1[random(sizeof(DrivSkinsL1))]);
SendClientMessage(playerid, COLOR_YELLOW, "Welcome in team Drivers! use * for a teamchat NOTE: Spray is tear gass! more about drivers: /drivers");
SendClientMessage(playerid, COLOR_YELLOW, "Your weapons: 9mm");
GameTextForPlayer(playerid, "~w~ Joined Team Drivers! (/drivers) (LVL 1___/l1)", 3000, 4);
}
if(IsLevel2[playerid] == 1)
{
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 50);
GivePlayerWeapon(playerid, 22, 20); //slot 2
GivePlayerWeapon(playerid, 17, 20);
SetPlayerSkin(playerid,DrivSkinsL2[random(sizeof(DrivSkinsL2))]);
SendClientMessage(playerid, COLOR_YELLOW, "Welcome in team Drivers! use * for a teamchat NOTE: Spray is tear gass! more about drivers: /drivers");
SendClientMessage(playerid, COLOR_YELLOW, "Your weapons: 9mm TearGas");
GameTextForPlayer(playerid, "~w~ Joined Team Drivers! (/drivers) (LVL 2___/l2)", 3000, 4);
}
if(IsLevel3[playerid] == 1)
{
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
GameTextForPlayer(playerid, "~w~ Joined Team Drivers! (/drivers) (LVL 3___/l3)", 3000, 4);
SendClientMessage(playerid, COLOR_YELLOW, "Welcome in team Drivers! use * for a teamchat NOTE: Spray is tear gass! more about drivers: /drivers");
SetPlayerSkin(playerid,DrivSkinsL3[random(sizeof(DrivSkinsL3))]);
}
}
if(iPickups[pickupid] != 0){
new vehicleid = GetPlayerVehicleID(playerid);
if(vehicleid != 0){
new panels, doors, lights, tires;
GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
UpdateVehicleDamageStatus(vehicleid, panels, doors, lights, 15);
}
}
return 1;
}
ok, so when I pickup the drivers pickup you can see that I use SetPlayerColor(playerid, COLOR_SEXYGREEN)
next code:
pawn Код:
if(vehicle == 516)
{
if(gTeam[playerid] == TEAM_DRIVERS)
{
if(IsWorking[playerid] == 0)
{
if(cinfo[playerid] == 1)
{
if(stw[playerid] == 0)
{
stw[playerid] = 1;
SendClientMessage(playerid, COLOR_LIGHTRED, "|~ U have entered a vehicle that can be used to do a Lvl 1 job. ~|");
SendClientMessage(playerid, COLOR_LIGHTRED, "|~ To start a Job, drive to the checkpoint, located in front of this tennis club. (at your teambase) ~|");
SendClientMessage(playerid, COLOR_LIGHTRED, "|~ Then u will get furture instructions. ~|");
SendClientMessage(playerid, COLOR_LIGHTRED, "|~ If u want to get a extra little bonus when u finish a job, ~|");
SendClientMessage(playerid, COLOR_LIGHTRED, "|~ then get as least Vehicle damage as possible.~ |");
SendClientMessage(playerid, COLOR_LIGHTRED, "|~ If u can't remember where your teambase is located use /home ~|");
SendClientMessage(playerid, COLOR_LIGHTRED, "|~ Type /cinfo if u don't want to display this no more when entering a Vehicle ~|");
SetPlayerCheckpoint(playerid,669.7355,-1275.9504,13.4609,2);
return 1;
}
}
}
}
}
ok, so you can see I have used if(gteam...) so when I enter vehicle id 516 I must get the messages...
Now, the problem:
When I pickup the pickup My color does not change to green... but it changes to the color from the cops, wich is COLOR_ROYALBLUE , so at first I thought that I accidentally have put SetPlayerColor(playerid, COLOR_ROYALBLUE) in my script somewhere else, so the color will turn blue, instead of green...
but I have checked my script, and didn't found any problems...
next, when I try to enter vehicle 516, as gTeam[playerid] = TEAM_DRIVERS;
It says that I'm in the incorrect team for this vehicle...
and none of the messages that show up...
any help?
if you can ill give u Rep, maybe two if that's legal on this forums...
Re: SetPlayerColor does not work... wtf? -
[MWR]Blood - 30.08.2011
First of all, are you sure you haven't defined TEAM_DRIVERS and TEAM_COPS with the same numbers?
About the second code, you are checking many other vars.
You might want try to temporarily remove them to see if the code works properly.
Re: SetPlayerColor does not work... wtf? -
knackworst - 30.08.2011
pawn Код:
#define TEAM_COPS 0
#define TEAM_DRIVERS 1
#define TEAM_BANDIT 2
#define TEAM_UNSPAWNED 3
that's my team defines :/
Re: SetPlayerColor does not work... wtf? -
[MWR]Blood - 30.08.2011
The other possibilities are, you defined the colors wrong, or the team numbers are being used by other things...
Re: SetPlayerColor does not work... wtf? -
knackworst - 30.08.2011
so what variables/defines/functions must I check then?
about the remove a var thing, you were right, I didn't put stw[playerid] = 0; under OnPlayerConnect
only problem is team
sorry I had to ask for help for that, I could have found it myself too :/
Under OnPlayerConnect
pawn Код:
gTeam[playerid] = TEAM_UNSPAWNED;
SetPlayerColor(playerid,COLOR_GREY);
under OnPlayerDisconnect
pawn Код:
SetPlayerColor(playerid, COLOR_GREY);
gTeam[playerid] = TEAM_UNSPAWNED;
under OnPlayerSpawn
pawn Код:
gTeam[playerid] = TEAM_UNSPAWNED;
SetPlayerColor(playerid,COLOR_GREY);
under OnPlayerDeath
pawn Код:
SetPlayerColor(playerid,COLOR_GREY);
gTeam[playerid] = TEAM_UNSPAWNED
under OnPlayerCommandText
pawn Код:
if (strcmp("/drivers", cmdtext, true, 10) == 0)
{
//gTeam[playerid] = 0;
gTeam[playerid] = TEAM_DRIVERS;
SetPlayerColor(playerid,COLOR_SEXYGREEN); // green
return 1;
}
if (strcmp("/b", cmdtext, true, 10) == 0)
{
//gTeam[playerid] = 0;
gTeam[playerid] = TEAM_BANDIT;
SetPlayerColor(playerid,COLOR_ORANGE); // orange
return 1;
}
if (strcmp("/c", cmdtext, true, 10) == 0)
{
//gTeam[playerid] = 0;
gTeam[playerid] = TEAM_COPS;
SetPlayerColor(playerid,COLOR_ROYALBLUE); // blue
return 1;
}
if (strcmp("/u", cmdtext, true, 10) == 0)
{
//gTeam[playerid] = 0;
gTeam[playerid] = TEAM_UNSPAWNED;
SetPlayerColor(playerid,COLOR_GREY); // grey
return 1;
}
this has been made for testing
and that are all my setplayercolor functions
Re: SetPlayerColor does not work... wtf? -
[MWR]Blood - 30.08.2011
Try replacing:
pawn Код:
#define COLOR_ROYALBLUE 0x009BFFFF
#define COLOR_SEXYGREEN 0x00EE14FF
Re: SetPlayerColor does not work... wtf? -
knackworst - 30.08.2011
wait...
I defined the wrong color -_-'''
how's that possible? yesterday the colors werer right, now they were switched, COLOR_SEXYGREEN was defined as blue...
anyways thanks for the help!
Re: SetPlayerColor does not work... wtf? -
[MWR]Blood - 30.08.2011
No problem, have fun, and good luck in scripting!
Re: SetPlayerColor does not work... wtf? -
knackworst - 30.08.2011
Thank you : D