Raised This Month: $51 Target: $400
 12% 

Vip free 22 - 10 has problems


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Pizzadaking
Member
Join Date: Oct 2019
Old 04-06-2020 , 16:30   Vip free 22 - 10 has problems
Reply With Quote #1

Hello so i managed to make this "vip" plugin free for at night : 22:00 - 10:00 but its not working , can someone help what ive done wrong ? im really bad at scripting by the way. ( the code compiles but on server it doesnt work )

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <amxconst>
#include <cstrike>
#include <fun>
#include <hamsandwich>
#include <fakemeta>
#include <engine>
#include <csx>

#define ADMIN_VIP ADMIN_LEVEL_H

new g_FreeVip[33];
new 
g_Time_1g_Time_2


enum 
{
    
SCOREATTRIB_ARG_PLAYERID 1,
    
SCOREATTRIB_ARG_FLAGS
};


enum ( <<= ) {
    
SCOREATTRIB_FLAG_NONE 0,
    
SCOREATTRIB_FLAG_DEAD 1,
    
SCOREATTRIB_FLAG_BOMB,
    
SCOREATTRIB_FLAG_VIP
};

new 
pCvar_AdminVIP;


public 
plugin_init()
{
    
register_plugin"Admin VIP ScoreBoard""0.0.1""Exolent" );
    
    
register_messageget_user_msgid"ScoreAttrib" ), "MessageScoreAttrib" );
    
    
pCvar_AdminVIP register_cvar"amx_adminvip""1" );
    
register_plugin("VIP Menu""1.0""Pizza");
    
register_clcmd("say /vm""ShowMenu");
    
register_concmd("say /vipextra","showmenuv");
    
g_Time_1 register_cvar("free_vip_time_from""22")
    
g_Time_2 register_cvar("free_vip_time_to""10")
    
    
RegisterHam(Ham_Spawn"player""fwHamPlayerSpawnPost"1)
        

     
}

public 
fwHamPlayerSpawnPost(id)
{
    new 
szTime[3]
    
get_time("%H",szTime,2)
    
    new 
Time_1 get_pcvar_num(g_Time_1)
    new 
Time_2 get_pcvar_num(g_Time_2)
    
    new 
iTime str_to_num(szTime)
    if( 
22 <= iTime <= 10 )
    {
       
            
g_FreeVip[id] = true;
            
set_hudmessage255255255, -1.00.8700.012.00.10.2, -);
            
show_hudmessage id"You get FREE VIP from %d:00 to %d:00!"Time_1Time_2)
        
    }
    else if( 
22 <= iTime <= 10 )
    {
        
            
g_FreeVip[id] = true;
            
set_hudmessage255255255, -1.00.8700.012.00.10.2, -);
            
show_hudmessage id"You get FREE VIP from %d:00 to %d:00!"Time_1Time_2)
        
    }
    else if( 
g_FreeVip[id] )
    {
        
g_FreeVip[id] = false;
    }


public 
showmenuv(id)
{
    new 
menu menu_create("VIP Extra Items""Pressedrod");
    
menu_additemmenu"\yRiffle Sniper \r[ \wg3sg1 \r]""0");
    
menu_additemmenu"\yM249  ""1");
     
    
menu_setpropmenuMPROP_EXITMEXIT_ALL );   
     
    
menu_displayidmenu);  
     
    return 
PLUGIN_HANDLED;
}

public 
ShowMenu(id)
{    
    if (
get_user_flags(id) & ADMIN_LEVEL_H)
    {
                new 
CsTeams:userTeam cs_get_user_team(id)
                if (
userTeam == CS_TEAM_CT)
                {
                
                    new 
menu menu_create("[\rBIBITA\y] VIP  Menu:""MohammadHlwani");

                    
menu_additem(menu"\r[\yExtra items\r]"""0); // case 0
                    
menu_additem(menu"\r[\yHealth Shop\r]"""0); // case 1
                    
menu_additem(menu"\r[\yGlow Menu\r]"""0); // case 2

                    
menu_setprop(menuMPROP_EXITMEXIT_ALL);

                    
menu_display(idmenu0);

                    return 
PLUGIN_HANDLED;
    
                } 
    }
    else if(
g_FreeVip[id])
    {
                new 
CsTeams:userTeam cs_get_user_team(id)
                if (
userTeam == CS_TEAM_CT)
                {
                
                    new 
menu menu_create("[\rBIBITA\y] VIP  Menu:""MohammadHlwani");

                    
menu_additem(menu"\r[\yExtra items\r]"""0); // case 0
                    
menu_additem(menu"\r[\yHealth Shop\r]"""0); // case 1
                    
menu_additem(menu"\r[\yGlow Menu\r]"""0); // case 2

                    
menu_setprop(menuMPROP_EXITMEXIT_ALL);

                    
menu_display(idmenu0);

                    return 
PLUGIN_HANDLED;
    
                }
    }
    return 
0;

}
public 
MohammadHlwani(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_cancel(id);
        return 
PLUGIN_HANDLED;
    }

    new 
command[6], name[64], accesscallback;

    
menu_item_getinfo(menuitemaccesscommandsizeof command 1namesizeof name 1callback);

    switch(
item)
    {
        case 
0client_cmd(id"say /vipextra");
//        case 1: client_cmd(id, "say /VIPmodels");
        
case 1client_cmd(id"say /hpshop");
        case 
2client_cmd(id"say /vipglow");
    }

    
menu_destroy(menu);

    return 
PLUGIN_HANDLED;
}


public 
MessageScoreAttribiMsgIdiDestiReceiver ) {
    if( 
get_pcvar_numpCvar_AdminVIP ) ) {
        new 
iPlayer get_msg_arg_intSCOREATTRIB_ARG_PLAYERID );
        
        if( 
accessiPlayerADMIN_VIP ) ) {
            
set_msg_arg_intSCOREATTRIB_ARG_FLAGSARG_BYTESCOREATTRIB_FLAG_VIP );
        }
    }
}

public 
Pressedrod(idmenuitem)
{
     if (
item == MENU_EXIT) { 
        
menu_destroy(menu
        return 
PLUGIN_HANDLED
    } 
    
    new 
data[6], szName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);
    new 
key str_to_num(data);
    
    if(!
is_user_alive(id))
        return 
PLUGIN_HANDLED
        
    
switch(key) {
        case 
0: { 
        
give_item(id,"weapon_g3sg1")
        
give_item(id,"ammo_762nato")
        
give_item(id,"ammo_762nato")
        
give_item(id,"ammo_762nato")
        }
        case 
1: {
        
give_item(id"weapon_m249")
        
cs_set_user_bpammo(idCSW_M249200)
        }
    }
    
    return 
PLUGIN_CONTINUE


/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ fbidis\\ ansi\\ ansicpg1252\\ deff0{\\ fonttbl{\\ f0\\ fnil\\ fcharset0 Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ ltrpar\\ lang10241\\ f0\\ fs16 \n\\ par }
*/ 
Pizzadaking is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-06-2020 , 19:29   Re: Vip free 22 - 10 has problems
Reply With Quote #2

Code:
if(22 <= iTime <= 10)

Just think about it. If it's currently 8 in the morning, will 22 be <= 8?

Use the function I gave you in your other thread and stop inventing alternative methods that won't work when you have a working one.

You're asking for help but constantly ignoring the answers.
__________________

Last edited by OciXCrom; 04-06-2020 at 19:30.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Pizzadaking
Member
Join Date: Oct 2019
Old 04-07-2020 , 04:48   Re: Vip free 22 - 10 has problems
Reply With Quote #3

so i added this


Quote:
bool:is_vip_hour(iStart, iEnd)
{
new iHour; time(iHour)
return booliStart < iEnd ? (iStart <= iHour < iEnd) : (iStart <= iHour || iHour < iEnd))
}

and this



Quote:
else if(is_vip_hour(22, 10))
{
new CsTeams:userTeam = cs_get_user_team(id)
if (userTeam == CS_TEAM_CT)
{

new menu = menu_create("[\rBIBITA\y] VIP Menu:", "MohammadHlwani");

menu_additem(menu, "\r[\yExtra items\r]", "", 0); // case 0
menu_additem(menu, "\r[\yHealth Shop\r]", "", 0); // case 1
menu_additem(menu, "\r[\yGlow Menu\r]", "", 0); // case 2

menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);

menu_display(id, menu, 0);

return PLUGIN_HANDLED;

}
}
Do u think it should work ?
Pizzadaking is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-07-2020 , 06:34   Re: Vip free 22 - 10 has problems
Reply With Quote #4

I don't see the full code, so I can't know what you've done - test it.

PS: from your original post:

Code:
if( 22 <= iTime <= 10 ) {                 g_FreeVip[id] = true;         set_hudmessage( 255, 255, 255, -1.0, 0.87, 0, 0.0, 12.0, 0.1, 0.2, -1 );         show_hudmessage ( id, "You get FREE VIP from %d:00 to %d:00!", Time_1, Time_2)         } else if( 22 <= iTime <= 10 ) {

What is this supposed to do? Why are you using the exact same condition twice with elseif?
Please try thinking about what you're doing when writing code. If you translate this part of the code to English, you'll get:

Code:
check if the number is between 22 and 10     do something if not, check if the number is between 22 and 10     do something else

It doesn't make sense, does it?
__________________

Last edited by OciXCrom; 04-07-2020 at 06:35.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Pizzadaking
Member
Join Date: Oct 2019
Old 04-07-2020 , 07:44   Re: Vip free 22 - 10 has problems
Reply With Quote #5

Quote:
Originally Posted by OciXCrom View Post
I don't see the full code, so I can't know what you've done - test it.

PS: from your original post:

Code:
if( 22 <= iTime <= 10 ) {                 g_FreeVip[id] = true;         set_hudmessage( 255, 255, 255, -1.0, 0.87, 0, 0.0, 12.0, 0.1, 0.2, -1 );         show_hudmessage ( id, "You get FREE VIP from %d:00 to %d:00!", Time_1, Time_2)         } else if( 22 <= iTime <= 10 ) {

What is this supposed to do? Why are you using the exact same condition twice with elseif?
Please try thinking about what you're doing when writing code. If you translate this part of the code to English, you'll get:

Code:
check if the number is between 22 and 10     do something if not, check if the number is between 22 and 10     do something else

It doesn't make sense, does it?
Well thanks for clarifying but i didnt make the script on my own as my scripting skills are 0 i just found a thread like this and did it ( someone had posted that if( 22 <= iTime <= 10)
Thats why i thought it would work

Here is full code:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <amxconst>
#include <cstrike>
#include <fun>
#include <hamsandwich>
#include <fakemeta>
#include <engine>
#include <csx>

#define ADMIN_VIP ADMIN_LEVEL_H


bool:is_vip_hour(iStartiEnd)
{
    new 
iHourtime(iHour)
    return 
bool:(iStart iEnd ? (iStart <= iHour iEnd) : (iStart <= iHour || iHour iEnd))




enum {
    
SCOREATTRIB_ARG_PLAYERID 1,
    
SCOREATTRIB_ARG_FLAGS
};


enum ( <<= ) {
    
SCOREATTRIB_FLAG_NONE 0,
    
SCOREATTRIB_FLAG_DEAD 1,
    
SCOREATTRIB_FLAG_BOMB,
    
SCOREATTRIB_FLAG_VIP
};

new 
pCvar_AdminVIP;


public 
plugin_init()
{
    
register_plugin"Admin VIP ScoreBoard""0.0.1""Exolent" );
    
    
register_messageget_user_msgid"ScoreAttrib" ), "MessageScoreAttrib" );
    
    
pCvar_AdminVIP register_cvar"amx_adminvip""1" );
    
register_plugin("VIP Menu""1.0""Pizza");
    
register_clcmd("say /vm""ShowMenu");
    
register_concmd("say /vipextra","showmenuv");
    
    
RegisterHam(Ham_Spawn"player""fwHamPlayerSpawnPost"1)
        

     
}


public 
showmenuv(id)
{
    new 
menu menu_create("VIP Extra Items""Pressedrod");
    
menu_additemmenu"\yRiffle Sniper \r[ \wg3sg1 \r]""0");
    
menu_additemmenu"\yM249  ""1");
    
menu_setpropmenuMPROP_EXITMEXIT_ALL );   
    
menu_displayidmenu);  
    return 
PLUGIN_HANDLED;
}

public 
ShowMenu(id)
{    
    if (
get_user_flags(id) & ADMIN_LEVEL_H)
    {
                new 
CsTeams:userTeam cs_get_user_team(id)
                if (
userTeam == CS_TEAM_CT)
                {
                
                    new 
menu menu_create("[\rBIBITA\y] VIP  Menu:""MohammadHlwani");

                    
menu_additem(menu"\r[\yExtra items\r]"""0); // case 0
                    
menu_additem(menu"\r[\yHealth Shop\r]"""0); // case 1
                    
menu_additem(menu"\r[\yGlow Menu\r]"""0); // case 2

                    
menu_setprop(menuMPROP_EXITMEXIT_ALL);

                    
menu_display(idmenu0);

                    return 
PLUGIN_HANDLED;
    
                } 
    }
    else if(
is_vip_hour(2210))
    {
                new 
CsTeams:userTeam cs_get_user_team(id)
                if (
userTeam == CS_TEAM_CT)
                {
                
                    new 
menu menu_create("[\rBIBITA\y] VIP  Menu:""MohammadHlwani");

                    
menu_additem(menu"\r[\yExtra items\r]"""0); // case 0
                    
menu_additem(menu"\r[\yHealth Shop\r]"""0); // case 1
                    
menu_additem(menu"\r[\yGlow Menu\r]"""0); // case 2

                    
menu_setprop(menuMPROP_EXITMEXIT_ALL);

                    
menu_display(idmenu0);

                    return 
PLUGIN_HANDLED;
    
                }
    }
    
    return 
0;

}
public 
MohammadHlwani(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_cancel(id);
        return 
PLUGIN_HANDLED;
    }

    new 
command[6], name[64], accesscallback;

    
menu_item_getinfo(menuitemaccesscommandsizeof command 1namesizeof name 1callback);

    switch(
item)
    {
        case 
0client_cmd(id"say /vipextra");
//        case 1: client_cmd(id, "say /VIPmodels");
        
case 1client_cmd(id"say /hpshop");
        case 
2client_cmd(id"say /vipglow");
    }

    
menu_destroy(menu);

    return 
PLUGIN_HANDLED;
}


public 
MessageScoreAttribiMsgIdiDestiReceiver ) {
    if( 
get_pcvar_numpCvar_AdminVIP ) ) {
        new 
iPlayer get_msg_arg_intSCOREATTRIB_ARG_PLAYERID );
        
        if( 
accessiPlayerADMIN_VIP ) ) {
            
set_msg_arg_intSCOREATTRIB_ARG_FLAGSARG_BYTESCOREATTRIB_FLAG_VIP );
        }
    }
}

public 
Pressedrod(idmenuitem)
{
     if (
item == MENU_EXIT) { 
        
menu_destroy(menu
        return 
PLUGIN_HANDLED
    } 
    
        new 
data[6], szName[64];
        new 
accesscallback;
        
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);
        new 
key str_to_num(data);
    
    if(!
is_user_alive(id))
        return 
PLUGIN_HANDLED
        
    
switch(key) {
        case 
0: { 
        
give_item(id,"weapon_g3sg1")
        
give_item(id,"ammo_762nato")
        
give_item(id,"ammo_762nato")
        
give_item(id,"ammo_762nato")
        }
        case 
1: {
        
give_item(id"weapon_m249")
        
cs_set_user_bpammo(idCSW_M249200)
        }
    }
    
    return 
PLUGIN_CONTINUE


/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ fbidis\\ ansi\\ ansicpg1252\\ deff0{\\ fonttbl{\\ f0\\ fnil\\ fcharset0 Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ ltrpar\\ lang10241\\ f0\\ fs16 \n\\ par }
*/ 
Pizzadaking is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-07-2020 , 09:07   Re: Vip free 22 - 10 has problems
Reply With Quote #6

There's no point in copy/pasting the code in two different checks. Just like English has the word "OR", coding has "||" which means OR. So, instead of:

Code:
if (get_user_flags(id) & ADMIN_LEVEL_H)     code else if (is_vip_hour(22, 10))     same code

Do:

Code:
if (get_user_flags(id) & ADMIN_LEVEL_H || is_vip_hour(22, 10))     code

Please use the requests section if you're not willing to learn, or at least try to understand what's happening in the code.

Also, #including every .inc file doesn't make the code better. You don't need 50% of those libraries.
__________________

Last edited by OciXCrom; 04-07-2020 at 09:09.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Pizzadaking
Member
Join Date: Oct 2019
Old 04-07-2020 , 14:43   Re: Vip free 22 - 10 has problems
Reply With Quote #7

Quote:
Originally Posted by OciXCrom View Post
There's no point in copy/pasting the code in two different checks. Just like English has the word "OR", coding has "||" which means OR. So, instead of:

Code:
if (get_user_flags(id) & ADMIN_LEVEL_H)     code else if (is_vip_hour(22, 10))     same code

Do:

Code:
if (get_user_flags(id) & ADMIN_LEVEL_H || is_vip_hour(22, 10))     code

Please use the requests section if you're not willing to learn, or at least try to understand what's happening in the code.

Also, #including every .inc file doesn't make the code better. You don't need 50% of those libraries.


well im trying to learn ,, i used the || before with my first code the
PHP Code:
 if( 22 <= iTime <= 10 
one but since it wasnt working i thought i made something wrong . Thanks anyway, and yeah good point ill remove the .inc files that arent necessary. Thanks
Pizzadaking is offline
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 04-08-2020 , 14:15   Re: Vip free 22 - 10 has problems
Reply With Quote #8

https://forums.alliedmods.net/showth...t=1263&page=15
change default access to t during your wanted time, easier
__________________
a simple act of caring creates an endless ripple.

Last edited by Nutu_; 04-08-2020 at 14:15.
Nutu_ is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 18:30.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode