SA-MP Forums Archive
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(playeridparams[])
{
    
SetTimerEx("Test"1000false"d"playerid);
    return 
1;
}
public 
Test(playerid)
{
    
SetTimerEx("Test1"10000"d"playerid);
    return 
1;
}
public 
Test1(playerid)
{
    
SetTimerEx("Test2"10000"d"playerid);
    return 
1;
}
public 
Test2(playerid)
{
    
SetTimerEx("Test3"10000"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(playeridparams[])
{
    
SetTimerEx("Test"1000false"dd"playerid,0);
    return 
1;
}
public 
Test(playerid,x)
{
    switch(
x)
    {
        case 
0SetTimerEx("Test"10000"dd"playerid,1);
        case 
1SetTimerEx("Test"10000"dd"playerid,2);
        case 
2Cig[playerid]--;
    }
    return 
1;




Re: How to improve this code to 1 public function - zowzow - 05.04.2019

Im not german.

Anyway, Thanks.