SA-MP Forums Archive
function argument may not have a default value. - 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: function argument may not have a default value. (/showthread.php?tid=602225)



function argument may not have a default value. - iLuXing - 04.03.2016

public function's arguments cant own a default value

Code:
forward kick(playerid, bool:check = false);
public kick(playerid, bool:check = false) {
	if(!kick) SetTimerEx("kick", 1000, false, "dd", playerid, true);
	else Kick(playerid);
}
Just make a simple example, and we complie it.
get a error about that.

Code:
error 059: function argument may not have a default value (variable "check")
long time not coding makes my programming disordered.Fxxk.


Re: function argument may not have a default value. - iLuXing - 04.03.2016

Code:
forward kick(playerid);
public kick(playerid) {
	static check[MAX_PLAYERS] = {false, ...};
	check[playerid] = true;
	if(!check[playerid]) SetTimerEx("kick", 1000, false, "d", playerid);
	else {
		check[playerid] = false;
		Kick(playerid);
	}
}



Re: function argument may not have a default value. - Threshold - 04.03.2016

You can't use default values in public functions.