How to improve this code to 1 public function - 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: How to improve this code to 1 public function (
/showthread.php?tid=665465)
How to improve this code to 1 public function -
zowzow - 05.04.2019
Call only 1 public function instead of this
PHP Code:
new Cig[MAX_PLAYERS];
forward Test(playerid);
forward Test1(playerid);
forward Test2(playerid);
forward Test3(playerid);
CMD:tests(playerid, params[])
{
SetTimerEx("Test", 1000, false, "d", playerid);
return 1;
}
public Test(playerid)
{
SetTimerEx("Test1", 1000, 0, "d", playerid);
return 1;
}
public Test1(playerid)
{
SetTimerEx("Test2", 1000, 0, "d", playerid);
return 1;
}
public Test2(playerid)
{
SetTimerEx("Test3", 1000, 0, "d", playerid);
return 1;
}
public Test3(playerid)
{
Cig[playerid]--;
return 1;
}
Re: How to improve this code to 1 public function -
Kaliber - 05.04.2019
//Edit: My bad hahaha xD
Wanted to say, there are a lot of ways
PHP Code:
new Cig[MAX_PLAYERS];
forward Test(playerid,x);
CMD:tests(playerid, params[])
{
SetTimerEx("Test", 1000, false, "dd", playerid,0);
return 1;
}
public Test(playerid,x)
{
switch(x)
{
case 0: SetTimerEx("Test", 1000, 0, "dd", playerid,1);
case 1: SetTimerEx("Test", 1000, 0, "dd", playerid,2);
case 2: Cig[playerid]--;
}
return 1;
}
Re: How to improve this code to 1 public function -
zowzow - 05.04.2019
Im not german.
Anyway, Thanks.