Help about 2 things -
ShoortyFl - 14.06.2015
Hi, i have 2 problems in my script first problem:
When i want to see leaders, i've created a dialog for that and it shows all leaders online but the problem is, it only shows one leader, and if there is 2 or more leaders online it will only show 1 leader online and i don't know how to fix it.
pawn Код:
CMD:lideri(playerid, params[])
{
new string[564];
foreach(Player, i)
{
if(IsPlayerConnected(i))
{
if(PI[i][Lider] == 1) { format(string, sizeof(string), "{FBDF89} (( {00C0FF}Policija: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d. {FBDF89}))", ImeIgraca(i), i, PI[i][Telefon]); }
else if(PI[i][Lider] == 2) { format(string, sizeof(string), "{FBDF89} (( {0049FF}Federalni Biro: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d. {FBDF89}))", ImeIgraca(i), i, PI[i][Telefon]); }
else if(PI[i][Lider] == 3) { format(string, sizeof(string), "{FBDF89} (( {FF00EA}Hitna Pomoc: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d. {FBDF89}))", ImeIgraca(i), i, PI[i][Telefon]); }
else if(PI[i][Lider] == 4) { format(string, sizeof(string), "{FBDF89} (( {C3C3C3}CNN: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d. {FBDF89}))", ImeIgraca(i), i, PI[i][Telefon]); }
else if(PI[i][Lider] == 5) { format(string, sizeof(string), "{FBDF89} (( {6EF83C}Grove Street: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d. {FBDF89}))", ImeIgraca(i), i, PI[i][Telefon]); }
else if(PI[i][Lider] == 6) { format(string, sizeof(string), "{FBDF89} (( {B700FF}Ballas: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d. {FBDF89}))", ImeIgraca(i), i, PI[i][Telefon]); }
else if(PI[i][Lider] == 7) { format(string, sizeof(string), "{FBDF89} (( {FFAF00}Hells Angels: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d. {FBDF89}))", ImeIgraca(i), i, PI[i][Telefon]); }
else if(PI[i][Lider] == 8) { format(string, sizeof(string), "{FBDF89} (( {F3FF02}Los Surrenos: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d. {FBDF89}))", ImeIgraca(i), i, PI[i][Telefon]); }
else if(PI[i][Lider] == 9) { format(string, sizeof(string), "{FBDF89} (( {A90202}Yamaguchi: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d. {FBDF89}))", ImeIgraca(i), i, PI[i][Telefon]); }
else if(PI[i][Lider] == 10) { format(string, sizeof(string), "{FBDF89} (( {FFA1A1}La Familia Sinatra: {FBDF89}{FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d. {FBDF89}))", ImeIgraca(i), i, PI[i][Telefon]); }
else if(PI[i][Lider] == 11) { format(string, sizeof(string), "{FBDF89} (( {FF00EA}The Pink Panthers: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d. ))", ImeIgraca(i), i, PI[i][Telefon]); }
else if(PI[i][Lider] == 12) { format(string, sizeof(string), "{FBDF89} (( {F300FF}Russian Mafia: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d. {FBDF89}))", ImeIgraca(i), i, PI[i][Telefon]); }
else if(PI[i][Lider] == 13) { format(string, sizeof(string), "{FBDF89} (( {F300FF}Hitman: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d. {FBDF89}))", ImeIgraca(i), i, PI[i][Telefon]); }
else if(PI[i][Lider] == 13) { format(string, sizeof(string), "{FBDF89} (( {B7FF00}Condor: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d. {FBDF89}))", ImeIgraca(i), i, PI[i][Telefon]); }
SPD(playerid, 1016, DIALOG_STYLE_MSGBOX, "Online Lideri", string, "Uredu", "");
}
}
return 1;
}
Second problem:
So, when i try to put a mask on me it wont change my name label it stays the same, and idk why, here is the code:
pawn Код:
CMD:maska(playerid, params[])
{
if(AdminDuznost[playerid] == 1 || GMDuznost[playerid] == 1) return SCM(playerid, TOMATO, "[RPF] {FFFFFF}Ne mozete koristiti ovu komandu dok ste na duznosti.");
if(PI[playerid][Maska] == 1)
{
new strn[128], name[24];
GetPlayerName(playerid, name, 24);
if(Maskiran[playerid] == false)
{
SCM(playerid, TOMATO, "[RPF] {FFFFFF}Stavili ste masku na glavu.");
format(strn, sizeof(strn), "(%d)Stranac", playerid);
SetPlayerAttachedObject(playerid, 2 ,19036,2,0.093999,0.026000,-0.004999,93.800018,82.199951,-3.300001,1.098000,1.139999,1.173000);
Maskiran[playerid] = true;
Update3DTextLabelText(Text3D:NameTag[playerid], WHITE, strn);
}
else if(Maskiran[playerid] == true)
{
SCM(playerid, TOMATO, "[RPF] {FFFFFF}Skinuli ste masku sa glave.");
format(strn, sizeof(strn), "%s", name);
Maskiran[playerid] = false;
if(IsPlayerAttachedObjectSlotUsed(playerid, 2)) RemovePlayerAttachedObject(playerid, 2);
Update3DTextLabelText(Text3D:NameTag[playerid], WHITE, strn);
}
}
else return SCM(playerid, TOMATO, "[RPF] {FFFFFF}Nemate masku, morate je kupiti.");
return 1;
}
Re: Help about 2 things -
Konstantinos - 14.06.2015
foreach loops through connected players ONLY so the check is not needed. The problem is that you format the message but you don't join it with the previous text. switch is also much faster than if/else if. You also got value 13 twice, I guess it's meant to be 14? If not, modify it. Last you forgot the new lines:
PHP код:
CMD:lideri(playerid, params[])
{
new string[564];
foreach(Player, i)
{
switch (PI[i][Lider])
{
case 1: format(string, sizeof(string), "%s{FBDF89} (( {00C0FF}Policija: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d.))\n", string, ImeIgraca(i), i, PI[i][Telefon]);
case 2: format(string, sizeof(string), "%s{FBDF89} (( {0049FF}Federalni Biro: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d.))\n", string, ImeIgraca(i), i, PI[i][Telefon]);
case 3: format(string, sizeof(string), "%s{FBDF89} (( {FF00EA}Hitna Pomoc: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d.))\n", string, ImeIgraca(i), i, PI[i][Telefon]);
case 4: format(string, sizeof(string), "%s{FBDF89} (( {C3C3C3}CNN: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d.))\n", string, ImeIgraca(i), i, PI[i][Telefon]);
case 5: format(string, sizeof(string), "%s{FBDF89} (( {6EF83C}Grove Street: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d.))\n", string, ImeIgraca(i), i, PI[i][Telefon]);
case 6: format(string, sizeof(string), "%s{FBDF89} (( {B700FF}Ballas: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d.))\n", string, ImeIgraca(i), i, PI[i][Telefon]);
case 7: format(string, sizeof(string), "%s{FBDF89} (( {FFAF00}Hells Angels: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d.))\n", string, ImeIgraca(i), i, PI[i][Telefon]);
case 8: format(string, sizeof(string), "%s{FBDF89} (( {F3FF02}Los Surrenos: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d.))\n", string, ImeIgraca(i), i, PI[i][Telefon]);
case 9: format(string, sizeof(string), "%s{FBDF89} (( {A90202}Yamaguchi: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d.))\n", string, ImeIgraca(i), i, PI[i][Telefon]);
case 10: format(string, sizeof(string), "%s{FBDF89} (( {FFA1A1}La Familia Sinatra: {FBDF89}{FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d.))\n", string, ImeIgraca(i), i, PI[i][Telefon]);
case 11: format(string, sizeof(string), "%s{FBDF89} (( {FF00EA}The Pink Panthers: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d.))\n", string, ImeIgraca(i), i, PI[i][Telefon]);
case 12: format(string, sizeof(string), "%s{FBDF89} (( {F300FF}Russian Mafia: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d.))\n", string, ImeIgraca(i), i, PI[i][Telefon]);
case 13: format(string, sizeof(string), "%s{FBDF89} (( {F300FF}Hitman: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d.))\n", string, ImeIgraca(i), i, PI[i][Telefon]);
case 14: format(string, sizeof(string), "%s{FBDF89} (( {B7FF00}Condor: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d.))\n", string, ImeIgraca(i), i, PI[i][Telefon]);
}
}
if (!isnull(string)) SPD(playerid, 1016, DIALOG_STYLE_MSGBOX, "Online Lideri", string, "Uredu", "");
return 1;
}
---
I don't know about the second problem but the tag is not needed:
pawn Код:
Update3DTextLabelText(NameTag[playerid], -1, strn);
Re: Help about 2 things -
Virtual1ty - 14.06.2015
For the first problem: you have to append the string each iteration or else you will get only the last player it looped through on the list.
Also DO NOT use IsPlayerConnected inside a foreach loop (unless you are not using the real "foreach" by ******, and you should!)
Example for only one leader:
Код:
CMD:lideri(playerid, params[])
{
new string[564];
foreach(Player, i)
{
if (PI[i][Lider] == 1) format(string, sizeof(string), "%s{FBDF89} (( {00C0FF}Policija: {FFFFFF}%s / {FBDF89}ID:{FFFFFF}%d / {FBDF89}Telefon: {FFFFFF}%d. {FBDF89}))", string, ImeIgraca(i), i, PI[i][Telefon]);
// more code
}
return 1;
}
Notice how I put "%s" in front of the string.
I have no idea what is wrong with the second one, try using the Streamer plugin.
Edit: seems like Konstantinos and I were writing at the same time, but he was faster, sorry!
Re: Help about 2 things -
ShoortyFl - 14.06.2015
Thanks guys, the first thing is working.
But the secon one is not, the labels wont change, and it bugs me alot, does anyone know what could cause the problem ?