SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 05/04/2019, 03:40 PM   #1
zowzow
Little Clucker
 
Join Date: Nov 2018
Location: Ifa4uu9T36
Posts: 32
Reputation: 0
Default How to improve this code to 1 public function

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;

zowzow is offline   Reply With Quote
Old 05/04/2019, 04:04 PM   #2
Kaliber
High-roller
 
Kaliber's Avatar
 
Join Date: Jun 2012
Location: Localhost
Posts: 1,065
Reputation: 151
Default Re: How to improve this code to 1 public function

//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;

__________________

Last edited by Kaliber; 05/04/2019 at 04:48 PM.
Kaliber is offline   Reply With Quote
Old 05/04/2019, 04:35 PM   #3
zowzow
Little Clucker
 
Join Date: Nov 2018
Location: Ifa4uu9T36
Posts: 32
Reputation: 0
Default Re: How to improve this code to 1 public function

Im not german.

Anyway, Thanks.
zowzow is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Detect House ID from Dialog[How to improve code optimization] GospodinX Scripting Help 5 31/08/2018 05:37 PM
Can someone help me check or improve some code xiaoniao Scripting Help 0 26/05/2016 12:38 AM
How to improve this function NinjaChicken Scripting Help 5 02/04/2013 01:39 AM
Do you guys know how you can improve lag - shooting..I want to improve. SpezzyBreeze General 9 26/12/2011 05:23 PM
Can You Improve This Code? mastalol Help Archive 13 20/07/2011 11:33 PM


All times are GMT. The time now is 11:08 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.