AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   add message (https://forums.alliedmods.net/showthread.php?t=327072)

Joker2020 08-31-2020 05:24

add message
 
how do I make it clear that the weapon is available from round 2?

Code:

if(get_user_flags(id) & ACCESS_FLAG)
        {
        if(g_RoundNum >= 2)

        {
                drop_weapons(id, 1);
                IsUserHaveAwp[id] = true;
                give_item_ex2(id, "weapon_awp", 30, true, IMPULSE);
        }else client_print(id, print_center, "available only to VIP players!");
    }
}

I tried it like this but it doesn't work
Code:

else
    {
            client_print(id, print_center, "available from round 2!");
        if(g_RoundNum >= 2)


DJEarthQuake 08-31-2020 09:08

Re: add message
 
Code:
if(get_user_flags(id) & ACCESS_FLAG && g_RoundNum >= 2 )                      /*Give VIP AWP round 2 and beyond*/     {                         drop_weapons(id, 1);         IsUserHaveAwp[id] = true;         give_item_ex2(id, "weapon_awp", 30, true, IMPULSE);     }         if( !(get_user_flags(id)&ACCESS_FLAG) && g_RoundNum >= 2 )                                                        /*NON-VIP*/             client_print(id, print_center, "available only to VIP players!");                 else                                             /*ROUND 1 MSG TO BE CLEAR ABOUT*/                     client_print(id, print_center, "available from round 2!");

anakonda001 08-31-2020 14:17

Re: add message
 
and this is where
client_print(id, print_center, "available from round 2!");

fysiks 08-31-2020 19:15

Re: add message
 
DJEarthQuake's code is quite wrong but your original code is very close to being correct. Where you currently have "available only to VIP players!" you should put "available from round 2!". Then, you need to add an else case for your access check if statement that says "available only to VIP players!".

P.S. If you properly format your code, it will make it much easier to read and understand (even for yourself). In fact, by just formatting your code, it showed that you had an extra unneeded brace (or missing a brace depending on if you prefer to add the braces for the else statement, which I always do so that it's less confusing later on):

PHP Code:

if(get_user_flags(id) & ACCESS_FLAG)
{
    if(
g_RoundNum >= 2)
    {
        
drop_weapons(id1);
        
IsUserHaveAwp[id] = true;
        
give_item_ex2(id"weapon_awp"30trueIMPULSE);
    }
    else
    {
        
client_print(idprint_center"available only to VIP players!");
    }


This formatting should make it easier to understand my answer in the first paragraph.

anakonda001 09-01-2020 02:51

Re: add message
 
Quote:

Originally Posted by fysiks (Post 2716188)
DJEarthQuake's code is quite wrong but your original code is very close to being correct. Where you currently have "available only to VIP players!" you should put "available from round 2!". Then, you need to add an else case for your access check if statement that says "available only to VIP players!".

PHP Code:

if(get_user_flags(id) & ACCESS_FLAG)
{
    if(
g_RoundNum >= 2)
    {
        
drop_weapons(id1);
        
IsUserHaveAwp[id] = true;
        
give_item_ex2(id"weapon_awp"30trueIMPULSE);
    }
    else
    {
        
client_print(idprint_center"available only to VIP players!");
    }


This formatting should make it easier to understand my answer in the first paragraph.

what the code should look like, please tell me

DJEarthQuake 09-01-2020 08:58

Re: add message
 
Quote:

Originally Posted by anakonda001 (Post 2716160)
and this is where
client_print(id, print_center, "available from round 2!");

I put it on there now.

fysiks 09-01-2020 23:07

Re: add message
 
Quote:

Originally Posted by anakonda001 (Post 2716219)
what the code should look like, please tell me

I told you exactly what to do:

Quote:

Originally Posted by fysiks (Post 2716188)
your original code is very close to being correct. Where you currently have "available only to VIP players!" you should put "available from round 2!". Then, you need to add an else case for your access check if statement that says "available only to VIP players!".

It's a real easy change that you can make and you'll be better off by doing it yourself. Try to do it yourself and if you still can't get it working, post your new code and we can help you finish it up.

Quote:

Originally Posted by DJEarthQuake (Post 2716240)
I put it on there now.

Your code is still overly complicated and confusing (and potential not even correct). Also, if you're going to help people out, you should reformat the code with proper indentation so it's easier to read and understand. You should know better, you've been writing code for a while now.


All times are GMT -4. The time now is 13:46.

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