Playerinfo Does'nt +1
#1

hello thi is my code
pawn Код:
forward RobBank(playerid);
public RobBank(playerid)
{
    new rand = random(130000)+0;
    new string[64];
    GivePlayerMoney(playerid,rand);
    format(string,sizeof string,"Your robbed $%d from the Bank",rand);
    SendClientMessage(playerid, -1, string);
    PlayerInfo[playerid][pRobberies] +1; // error line
    SendClientMessage(playerid, COLOR_GREEN, "You Rob the bank and now have 3 wanted level!");
    TogglePlayerControllable(playerid,1);
    return 1;
}
But i get an warn

C:\Users\Mustafa\Desktop\GTA Server AMCNR\gamemodes\AMCNR.pwn(101 : warning 215: expression has no effect
Reply
#2

Yes, But its actualy has a effect its +1 at him Data
Reply
#3

First of all, what on earth is the point in adding 0 to a value?

Thirdly:

pawn Код:
forward RobBank(playerid);
public RobBank(playerid)
{
    new rand = random(130000);
    new string[64];
    GivePlayerMoney(playerid, rand);
    format(string, sizeof string, "Your robbed $%d from the bank!", rand);
    SendClientMessage(playerid, -1, string);
    PlayerInfo[playerid][pRobberies] ++;
    SendClientMessage(playerid, COLOR_GREEN, "You robbed the bank and now have a wanted level of 3!");
    TogglePlayerControllable(playerid, true);
    return 1;
}
Fourthly, put spaces after commas so it's easier to read your code (just like when writing sentences!).
Reply
#4

This works:
pawn Код:
forward RobBank(playerid);
public RobBank(playerid)
{
    new rand = random(130000)+0;
    new string[64];
    GivePlayerMoney(playerid,rand);
    format(string,sizeof string,"Your robbed $%d from the Bank",rand);
    SendClientMessage(playerid, -1, string);
    PlayerInfo[playerid][pRobberies] += 1; // error line
    SendClientMessage(playerid, COLOR_GREEN, "You Rob the bank and now have 3 wanted level!");
    TogglePlayerControllable(playerid,1);
    return 1;
}
The mistake is in doing '+', which doesn't works. It's '+=' which means current value + 1. You can also use '++' for doing +1 only and '--' for -1.

#Late post..
Reply
#5

Thanks Lordz +REP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)