Help with setplayercolor() - 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: Help with setplayercolor() (
/showthread.php?tid=540453)
Help with setplayercolor() -
SkyLineGT - 04.10.2014
So basically i've developed a gang based (colored)bandana system, im not very good at coding, so heres what i've come up with:
Код:
CMD:setgangcolor(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 4)
{
new string[128], family, color[32];
if(sscanf(params, "is", family, color))
{
SendClientMessageEx(playerid, COLOR_GRAD1, "USAGE: /setgangcolor [familyid] [RRGGBBAA]");
return 1;
}
if(family < 1 || family > 10) return SendClientMessage(playerid, COLOR_WHITE, "Invalid Gang ID.");
if(FamilyInfo[family][FamilyTaken] != 1)
{
SendClientMessage(playerid, COLOR_GREY, " That gang isn't being used.");
return 1;
}
if(AdminDuty[playerid] != 1 && PlayerInfo[playerid][pAdmin] < 6)
{
SendClientMessage(playerid,COLOR_WHITE, "You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
return 1;
}
format(FamilyInfo[family][FamilyBandana], sizeof(color), color;
format(string, sizeof(string), "AdmCmd: %s has set gang ID %d's bandana to '%s'.", GetPlayerNameEx(playerid), family, color);
ABroadCast(COLOR_LIGHTRED, string, 1);
}
return 1;
}
As for the problem(what i think):
Код:
CMD:bandana(playerid, params[])
{
new string[128], gangcolor;
if(PlayerInfo[playerid][pGang] == 255) return SendClientMessageEx(playerid, COLOR_WHITE, "Your not in a gang.");
if(FamilyInfo[PlayerInfo[playerid][pGang]][FamilyBandana] == 0) return SendClientMessageEx(playerid, COLOR_GRAD1, "Your gang does not have a bandana set.");
gangcolor = strval(FamilyInfo[PlayerInfo[playerid][pGang]][FamilyBandana]);
if(PlayerInfo[playerid][pBandana] != 1)
{
SetPlayerColor(playerid, gangcolor);
PlayerInfo[playerid][pBandana] = 1;
}
else
{
SetPlayerColor(playerid, TEAM_HIT_COLOR);
PlayerInfo[playerid][pBandana] = 0;
}
return 1;
}
The Problem: the problem is when i do /bandana it just turns my nametag black, i think the problem is i am taking color as a string, while if i take it as a integer sscanf doesnt let me do /setgangcolor, please help me!
Re: Help with setplayercolor() -
TakeiT - 05.10.2014
Try this, I used it for an ingame SetObjectMaterial thingy a while back. (I didn't make this, but i'm not sure who did, sorry)
pawn Код:
HexToInt(string[])
{
if (string[0]==0) return 0;
new i;
new cur=1;
new res=0;
for (i=strlen(string);i>0;i--) {
if (string[i-1]<58) res=res+cur*(string[i-1]-48); else res=res+cur*(string[i-1]-65+10);
cur=cur*16;
}
return res;
}