SA-MP Forums Archive
Basic question - removing entered value from variable - 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: Basic question - removing entered value from variable (/showthread.php?tid=562458)



Basic question - removing entered value from variable - ross8839 - 09.02.2015

pawn Код:
CMD:sell(playerid, params[])
{
    new Float:x,Float:y,Float:z;
    new string[128];
    new goldent;
    GetPlayerPos(playerid,x , y, z);
    if(sscanf(params,"i", goldent)) return SendClientMessage(playerid, -1, "usage...");
    if(!IsPlayerInRangeOfPoint(playerid, 7.0,x,y,z)) return SendClientMessage(playerid, -1, "Not in range!");
    GivePlayerMoney(playerid, 100*goldent);
    gold[playerid] - goldent;
    format(string, sizeof(string),"You have sold %i gold",goldent);
    SendClientMessage(playerid, -1, string);
    return 1;
}
how is it i get this warning

Код:
CMD:sell(playerid, params[])

C:\Users\Ross\Desktop\samp scripting\gamemodes\mining.pwn(54) : warning 215: expression has no effect
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.


on line: gold[playerid] - goldent;
I want to remove the entered value, for example... /sell 2, I had 5, but have 3 left...


Re: Basic question - removing entered value from variable - Schneider - 09.02.2015

Use -= to subtract a certain amount from a variable.

(Use += to add something, use -- to subtract 1 and ++ to add 1).

pawn Код:
gold[playerid] -= goldent;