SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 20/01/2020, 03:28 PM   #1
VGAassassin
Little Clucker
 
Join Date: Jul 2017
Posts: 37
Reputation: 0
Default Timer for ADS

How can I do when the AdTimer passes the ad is removed from the dialog and the next one is added above, help.


CMD:adqueue(playerid, params[])
{
new szStr[256];
format(szStr, 256, " (ID: %d)(%d) AD: %s\n (ID: %d)(%d) AD: %s\n (ID: %d)(%d) AD: %s\n (ID: %d)(%d) AD: %s\n (ID: %d)(%d) AD: %s",
GetName(playerid),AdTimer[0],AdText[0],GetName(playerid),AdTimer[1],AdText[1],GetName(playerid),AdTimer[2],AdText[2],GetName(playerid),AdTimer[3],AdText[3],GetName(playerid),AdTimer[4],AdText[4],GetName(playerid),AdTimer[5],AdText[5]);
ShowPlayerDialog(playerid, DIALOG_ADS, DIALOG_STYLE_LIST, "Ads",szStr,"OK","Cancel");
return true;
}
VGAassassin is offline   Reply With Quote
Old 20/01/2020, 06:40 PM   #2
ShadowMortar
Huge Clucker
 
ShadowMortar's Avatar
 
Join Date: Jul 2016
Location: Croatia
Posts: 279
Reputation: 56
Default Re: Timer for ADS

PHP Code:
#include         < a_samp >
#include         < sscanf2 >
#include         < zcmd >
#include         < YSI\y_timers >

#if !defined         MAX_ADVERTISEMENTS
    #define         MAX_ADVERTISEMENTS                ( MAX_PLAYERS * 2 )
#endif

#if !defined         MAX_ADVERTISEMENT_TEXT
    #define         MAX_ADVERTISEMENT_TEXT            ( 140 )
#endif

#if !defined         INVALID_ADVERTISEMENT_ID
    #define         INVALID_ADVERTISEMENT_ID        ( -1 )
#endif

#if !defined         DEFAULT_ADVERTISEMENT_COOLDOWN
    #define         DEFAULT_ADVERTISEMENT_COOLDOWN    ( 60 )
#endif

enum E_DATA_ADVERTISEMENT {
    
E_ADVERTISEMENT_ID,
    
E_ADVERTISEMENT_PHONE,
    
E_ADVERTISEMENT_TEXTMAX_ADVERTISEMENT_TEXT char ],
    
E_ADVERTISEMENT_COOLDOWN
};
enum E_DATA_PLAYER {
    
bool:E_PLAYER_HASPHONE,
    
E_PLAYER_PHONENUMBER
};
new 
AdvertisementMAX_ADVERTISEMENTS ] [ E_DATA_ADVERTISEMENT ], PlayerMAX_PLAYERS ] [ E_DATA_PLAYER ];

CMD:randomnumberplayerid ) {
    new 
rand 1000+random99999 );
    if( 
Playerplayerid ] [ E_PLAYER_HASPHONE ] ) return SendClientMessageplayerid, -1"{9E4141}| ERROR: | {FFFFFF}You already have a cellphone!" );
    
Playerplayerid ] [ E_PLAYER_HASPHONE ] = true;
    
Playerplayerid ] [ E_PLAYER_PHONENUMBER ] = rand;
    
SendClientMessageExplayerid, -1"{02B0F5}| SERVER: | {FFFFFF}You have been {17BF41}successfully {FFFFFF}given a cellphone, your number is %d"Playerplayerid ] [ E_PLAYER_PHONENUMBER ] );
    return ( 
true );
}

CMD:advertiseplayeridparams[ ] ) return cmd_adplayeridparams );
CMD:adplayeridparams[ ] ) {
    new 
txt140 ], cooldown AD_FetchLastID( );
    if( !
Playerplayerid ] [ E_PLAYER_HASPHONE ] ) return SendClientMessageplayerid, -1"{9E4141}| ERROR: | {FFFFFF}You do not have a cellphone!" );
    else if( 
sscanfparams"s[140]"txt ) ) return SendClientMessageplayerid, -1"| USAGE: | /(ad)vertise [Text]" );
    return 
AD_StoreAdvertisementtxtPlayerplayerid ] [ E_PLAYER_PHONENUMBER ], 
                                  ( 
cooldown == -) ? ( DEFAULT_ADVERTISEMENT_COOLDOWN ) : ( Advertisementcooldown ] [ E_ADVERTISEMENT_COOLDOWN ]+60 ), playerid );
}

CMD:adsplayerid ) return cmd_advertisementsplayerid );
CMD:advertisementsplayerid ) {
    new 
tmp 300 ], str900 ];
    for( new 
isizeofAdvertisement ), advertMAX_ADVERTISEMENT_TEXT char ]; ji++ ) {
        if( 
Advertisement] [ E_ADVERTISEMENT_ID ] != INVALID_ADVERTISEMENT_ID ) { 
            
AD_FetchAdvertisementiadvert );
            
formattmpsizeoftmp ), "#\tAdvert\t\tAirs in\n%d\t%s\t\t~%ds\t"i+1advertAdvertisement] [ E_ADVERTISEMENT_COOLDOWN ] );
            
strcatstrtmp );
        }
    }
    
ShowPlayerDialogplayerid1DIALOG_STYLE_TABLIST_HEADERS"Advertisements"str"Close""" );
    return ( 
true );
}

public 
OnFilterScriptInit( ) {
    
AD_SetupArray( );
    return ( 
true );
}

public 
OnPlayerDisconnectplayeridreason ) {
    
Playerplayerid ] [ E_PLAYER_HASPHONE ] = false;
    
Playerplayerid ] [ E_PLAYER_PHONENUMBER ] = 0;
    return ( 
true );
}

AD_SetupArray( ) {
    for( new 
isizeofAdvertisement ); ji++ ){
        
Advertisement] [ E_ADVERTISEMENT_ID ] = INVALID_ADVERTISEMENT_ID;
    }
    return ( 
true );
}

AD_StoreAdvertisementtxt[ ], phonenumbercooldown DEFAULT_ADVERTISEMENT_COOLDOWNplayerid ) {
    new 
id AD_FetchFreeID( );
    if( 
id == INVALID_ADVERTISEMENT_ID ) return SendClientMessageplayerid, -1"{9E4141}| ERROR: | {FFFFFF}Advertisement unsuccessfully placed, please try again later." );
    
SendClientMessageplayerid, -1"{17BF41}You have submitted an advertisement to the queue! (/ads to check when it will air)" );
    
Advertisementid ] [ E_ADVERTISEMENT_ID ] = id;
    
Advertisementid ] [ E_ADVERTISEMENT_COOLDOWN ] = cooldown;
    
Advertisementid ] [ E_ADVERTISEMENT_PHONE ] = phonenumber;
    
strpackAdvertisementid ] [ E_ADVERTISEMENT_TEXT ], txt );
    return ( 
true );
}

SendAdvertisementid ) {
    new 
adMAX_ADVERTISEMENT_TEXT char ], strMAX_ADVERTISEMENT_TEXT+20 ];
    
AD_FetchAdvertisementidad );
    
formatstrsizeofstr ), "{17BF41}[Advertisement] %s [PH: %d]"adAdvertisementid ] [ E_ADVERTISEMENT_PHONE ] );
    
SendClientMessageToAll( -1str );
    
Advertisementid ] [ E_ADVERTISEMENT_ID ] = INVALID_ADVERTISEMENT_ID;
    
Advertisementid ] [ E_ADVERTISEMENT_COOLDOWN ] = DEFAULT_ADVERTISEMENT_COOLDOWN;
    
Advertisementid ] [ E_ADVERTISEMENT_PHONE ] = 0;
    return ( 
true );
}

task OneSecondCheck[1000]() {
    for( new 
isizeofAdvertisement ); ji++ ) {
        if( 
Advertisement] [ E_ADVERTISEMENT_ID ] != INVALID_ADVERTISEMENT_ID ) {
            
Advertisement] [ E_ADVERTISEMENT_COOLDOWN ] --;
            if( 
Advertisement] [ E_ADVERTISEMENT_COOLDOWN ] < SendAdvertisement); 
        }
                else continue;
    }
    return ( 
true );
}

AD_FetchLastID( ) {
    new 
id = -1;
    for( new 
isizeofAdvertisement ); ji++ ) {
        if( 
Advertisement] [ E_ADVERTISEMENT_ID ] != INVALID_ADVERTISEMENT_ID id++;
        else continue;
    }
    return ( 
id );
}

AD_FetchFreeID( ) {
    for( new 
isizeofAdvertisement ); ji++ ) {
        if( 
Advertisement] [ E_ADVERTISEMENT_ID ] == INVALID_ADVERTISEMENT_ID ) return ( );
        else continue;
    }
    return ( 
INVALID_ADVERTISEMENT_ID );
}
AD_FetchAdvertisementidmsgMAX_ADVERTISEMENT_TEXT char ] ) {
    for( new 
isizeofAdvertisement ); ji++ ) {
        if( 
Advertisement] [ E_ADVERTISEMENT_ID ] == id strunpackmsgAdvertisement] [ E_ADVERTISEMENT_TEXT ] );
        else continue;
    }
    return ( 
true );
}

SendClientMessageExplayeridcolor, const text[ ], { Float}:... ) {
    static 
argsstr144 ];  
    if( ( 
args numargs( ) ) == ){
        
SendClientMessageplayeridcolortext );
    } else {
        while( --
args >= ) {
            
#emit LCTRL 5
            #emit LOAD.alt args
            #emit SHL.C.alt 2
            #emit ADD.C 12
            #emit ADD
            #emit LOAD.I
            #emit PUSH.pri
        
}
        
#emit PUSH.S text
        #emit PUSH.C 144
        #emit PUSH.C str
        #emit PUSH.S 8
        #emit SYSREQ.C format
        #emit LCTRL 5
        #emit SCTRL 4
        
SendClientMessage(playeridcolorstr);
        
#emit RETN
    
}
    return ( 
true );

This should work mate.
__________________
Quote:
Originally Posted by CheezIt View Post
Follow your heart and own style.
Feel free to PM me if you need help.
Quote:
Originally Posted by Pottus View Post
That is perfectly fine, I'm just pointing out where you made mistakes what does hearing "good job" get you? Absolutely nothing. You need to hear the problems otherwise you'll keep making the same mistakes
ShadowMortar 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
Performance Question , Per Player Timer vs Timer that loops through all players BiosMarcel Scripting Help 14 12/12/2016 09:50 AM
If /foodsearch doesn't find item, set wait timer (TIMER HELP) Josh_Main Scripting Help 7 14/09/2016 04:13 PM
Which is better Per Player Timer or Global timer? (issue with timer) Dokins Scripting Help 4 07/06/2016 09:50 AM
Slice's Timer Fix include --> timer public function isn't getting called Riwerry Scripting Help 0 02/01/2016 03:50 PM
[Timer Help] Score saving timer, should it always be running or should it be killed? Ghost100 Scripting Help 6 08/10/2012 10:12 PM


All times are GMT. The time now is 06:48 PM.


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