open.mp forum
[Pawn] Why my code only sends "else"? - Printable Version

+ open.mp forum (https://forum.open.mp)
-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
--- Thread: [Pawn] Why my code only sends "else"? (/showthread.php?tid=1562)



Why my code only sends "else"? - sampaux - 2021-01-20

Code:
for(new i = 0;i < 100;i)

{

if(PlayerInfo[i][cargo] != 0)

{

? ? GameTextForPlayer(i, "~r~Novo Report!", 3000, 5);

? ? GetPlayerName(id, reportado, sizeof(reportado));

? ? GetPlayerName(playerid, reportador, sizeof(reportador));

? ? format(report, sizeof(report), "Nick e id: %s [%d]\nMotivo: %s\nReportado por: %s", reportado, id, motivo, reportador);

? ? SendClientMessage(i, -1, "====={4291ff}Novo Report{FFFFFF}=====");

? ? SendClientMessage(i, -1, report);

}

else

{

SendClientMessage(i, -1, "asdadsadad");//I put it?in else?to prove that code only sends else

}



this code is a /report command. PlayerInfo[][cargo] == Admin level

despite my PlayerInfo[][cargo] != 0 in?game, this code keep sending the else,? considering?PlayerInfo[][cargo] == 0

Basically, it sends "?SendClientMessage(i, -1, "asdadsadad"); " for all online admins instead of the fist code,?and this is not what should happen



Fix it?is easy, obviously just invert?the codes.?But i want know WHY THIS OCCURS???


RE: Why my code only sends "else"? - LinesinRows - 2021-01-20

(2021-01-20, 12:50 PM)sampaux Wrote:
Code:
for(new i = 0;i < 100;i)

{

? if(PlayerInfo[i][cargo] != 0)

? {

? ? GameTextForPlayer(i, "~r~Novo Report!", 3000, 5);

? ? GetPlayerName(id, reportado, sizeof(reportado));

? ? GetPlayerName(playerid, reportador, sizeof(reportador));

? ? format(report, sizeof(report), "Nick e id: %s [%d]\nMotivo: %s\nReportado por: %s", reportado, id, motivo, reportador);

? ? SendClientMessage(i, -1, "====={4291ff}Novo Report{FFFFFF}=====");

? ? SendClientMessage(i, -1, report);

? }

? else

? {

? ? ?SendClientMessage(i, -1, "asdadsadad");//I put it?in else?to prove that code only sends else

? }

}





When u make a user is an admin, do u change the?PlayerInfo[playerid][cargo] value?