get the increased value of money -
VanillaRain - 30.07.2015
Hello I've tried to get the increased value of money doing like so but i got this errors:
Code:
C:\Users\Lorenzo\Desktop\samp server\filterscripts\Premium 2.pwn(132) : error 029: invalid expression, assumed zero
C:\Users\Lorenzo\Desktop\samp server\filterscripts\Premium 2.pwn(137) : error 029: invalid expression, assumed zero
ERRORS ON RED JUST DOWN HERE
Code:
public OnPlayerUpdate(playerid)
{
static a[ MAX_PLAYERS ];
static PlayerMoney[ MAX_PLAYERS ];
if(!PlayerMoney[ playerid ])
PlayerMoney[ playerid ] = GetPlayerMoney(playerid);
a[ playerid ] = (GetPlayerMoney(playerid) - PlayerMoney[ playerid ]);
else
{
if a[ playerid ] != 0
{
for (new i=0;i<MAX_PLAYERS;i++)
{
if (IsPlayerConnected(i))
{
if (IsPlayerAdmin(i))
{
SendClientMessage(i, 0xFF3300, "WARNING! %s money has been increased by: ", a );
}
}
}
}
PlayerMoney[ playerid ] = GetPlayerMoney(playerid);
}
return 1;
}
Some help?
Re: get the increased value of money -
dominik523 - 30.07.2015
Did you want to write this?
pawn Code:
if(!PlayerMoney[ playerid ])
{
PlayerMoney[ playerid ] = GetPlayerMoney(playerid);
a[ playerid ] = (GetPlayerMoney(playerid) - PlayerMoney[ playerid ]);
}
else
{
...
Or what? I hope your script doesn't have the same indentation.
Re: get the increased value of money -
VanillaRain - 30.07.2015
Quote:
Originally Posted by dominik523
Did you want to write this?
pawn Code:
if(!PlayerMoney[ playerid ]) { PlayerMoney[ playerid ] = GetPlayerMoney(playerid); a[ playerid ] = (GetPlayerMoney(playerid) - PlayerMoney[ playerid ]); } else { ...
Or what? I hope your script doesn't have the same indentation.
|
To make it more understandable:
Player XYZ got 2000$ then he got 3000$ so he have now 5000$
Well i would like to inform admins that Player XYZ gained 3000$
Re: get the increased value of money -
VanillaRain - 30.07.2015
uuuuuuuuuuuuuuuuup
Re: get the increased value of money -
liquor - 30.07.2015
First off, It is always better to use a timer than OnPlayerUpdate.
OnPlayerUpdate will run your code ~30 times per second, and there are
very few codes that require this.
static a[ MAX_PLAYERS ];
static PlayerMoney[ MAX_PLAYERS ];
pawn Code:
if(!PlayerMoney[ playerid ])
This means "if PlayerMoney[playerid] is NOT 1. So the code below will only run if
PlayerMoney[playerid] is not $1.
pawn Code:
PlayerMoney[ playerid ] = GetPlayerMoney(playerid);
This sets PlayerMoney[playerid] to whatever their cash is, even if they
cheated. So there won't be any difference, and the code below won't run.
pawn Code:
a[ playerid ] = (GetPlayerMoney(playerid) - PlayerMoney[ playerid ]);
Now a[playerid], PlayerMoney[playerid] and GetPlayerMoney(playerid) will return the same amount.
The code below will now only run, if PlayerMoney[playerid] returns $1 (as explained at the top)
if a[ playerid ] != 0
{
pawn Code:
for (new i=0;i<MAX_PLAYERS;i++)
{
This will loop through all players 30 times for every player that is online.
If you have 10 players the code will run 300 times per second. OnPlayerUpdate is already
a loop through all players.
This is better off in a timer.
if (IsPlayerConnected(i))
{
if (IsPlayerAdmin(i))
{
pawn Code:
SendClientMessage(i, 0xFF3300, "WARNING! %s money has been increased by: ", a );
This won't work, you need to format a string including playername, such as;
pawn Code:
new name[MAX_PLAYERNAME],str[64];
GetPlayerName(name,sizeof(name);
format(str,sizeof(str),"WARNING! %s's money has been increased by: $%d",name,a);
SendClientMessage(i,0xFF3300,str);
}
}
}
}
pawn Code:
PlayerMoney[ playerid ] = GetPlayerMoney(playerid);
This will not make any difference, with the code looking like it does now.
}
return 1;
}
Re: get the increased value of money -
VanillaRain - 30.07.2015
Quote:
Originally Posted by liquor
First off, It is always better to use a timer than OnPlayerUpdate.
OnPlayerUpdate will run your code ~30 times per second, and there are
very few codes that require this.
static a[ MAX_PLAYERS ];
static PlayerMoney[ MAX_PLAYERS ];
pawn Code:
if(!PlayerMoney[ playerid ])
This means "if PlayerMoney[playerid] is NOT 1. So the code below will only run if
PlayerMoney[playerid] is not $1.
pawn Code:
PlayerMoney[ playerid ] = GetPlayerMoney(playerid);
This sets PlayerMoney[playerid] to whatever their cash is, even if they
cheated. So there won't be any difference, and the code below won't run.
pawn Code:
a[ playerid ] = (GetPlayerMoney(playerid) - PlayerMoney[ playerid ]);
Now a[playerid], PlayerMoney[playerid] and GetPlayerMoney(playerid) will return the same amount.
The code below will now only run, if PlayerMoney[playerid] returns $1 (as explained at the top)
if a[ playerid ] != 0
{
pawn Code:
for (new i=0;i<MAX_PLAYERS;i++) {
This will loop through all players 30 times for every player that is online.
If you have 10 players the code will run 300 times per second. OnPlayerUpdate is already
a loop through all players.
This is better off in a timer.
if (IsPlayerConnected(i))
{
if (IsPlayerAdmin(i))
{
pawn Code:
SendClientMessage(i, 0xFF3300, "WARNING! %s money has been increased by: ", a );
This won't work, you need to format a string including playername, such as;
pawn Code:
new name[MAX_PLAYERNAME],str[64]; GetPlayerName(name,sizeof(name); format(str,sizeof(str),"WARNING! %s's money has been increased by: $%d",name,a); SendClientMessage(i,0xFF3300,str);
}
}
}
}
pawn Code:
PlayerMoney[ playerid ] = GetPlayerMoney(playerid);
This will not make any difference, with the code looking like it does now.
}
return 1;
}
|
So resuming with a working example? So I can comparate the both codes and look where I was wrong?
Re: get the increased value of money -
VanillaRain - 31.07.2015
Uuuuuuuuuup