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

if (user_has_weapon) problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Zkespinto
Junior Member
Join Date: Jul 2011
Old 10-10-2011 , 15:02   if (user_has_weapon) problem
Reply With Quote #1

Hi everyone. I'm having a problem with this plugin.

I would like to give this instruction the the plugin:

If a user has weapon deagle, he would get it again, after he choose the option menu 1 or 2. I would like the plugin to give ammo for the deagle also.

(In the same way the original plugins is saying that if the user has c4 he will get it again after he chooses option menu 1 or 2)


PHP Code:
public Showrod(id) {
    
show_menu(idKeysrod"    Menu VIP^n    1. Receber 14.000 $^n    2. Receber 250 HP^n    0. Sair^n", -1"rod"//   Display menu
}
public 
Pressedrod(idkey) {
    
/* Menu:
    * VIP Menu
    * 1. Get M4A1+Deagle
    * 2. Get AK47+Deagle
    * 0. Exit
    */
    
switch (key) {
        case 
0: { 
            if (
user_has_weapon(idCSW_C4) && get_user_team(id) == 1)
                
HasC4[id] = true;
            else
                
HasC4[id] = false;
 
            
strip_user_weapons (id)
            
give_item(id,"weapon_knife")
            
cs_set_user_money(id,14000)
            
client_print(idprint_center"Recebeste 14.000 $")
 
            if (
HasC4[id])
            {
                
give_item(id"weapon_c4");
                
cs_set_user_plantid );
            }
            }
        case 
1: { 
            if (
user_has_weapon(idCSW_C4) && get_user_team(id) == 1)
                
HasC4[id] = true;
            else
                
HasC4[id] = false;
 
            
strip_user_weapons (id)
            
give_item(id,"weapon_knife")
            
set_user_health(id250)
            
client_print(idprint_center"Recebeste 250 HP")
 
            if (
HasC4[id])
            {
                
give_item(id"weapon_c4");
                
cs_set_user_plantid );

            }
            }
        
        case 
9: {             
        }
    }
    return 
PLUGIN_CONTINUE



Thank you.
Zkespinto is offline
Nur56
Member
Join Date: Apr 2007
Old 10-10-2011 , 15:09   Re: if (user_has_weapon) problem
Reply With Quote #2

use

PHP Code:
if( get_user_weapon(id) == CSW_DEAGLE ) { } 
Nur56 is offline
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 10-10-2011 , 15:09   Re: if (user_has_weapon) problem
Reply With Quote #3

EDIT: This code is updated, and it will give deagle if player had a deagle.
PHP Code:
public Showrod(id) {
    
show_menu(idKeysrod"    Menu VIP^n    1. Receber 14.000 $^n    2. Receber 250 HP^n    0. Sair^n", -1"rod"//   Display menu
}
public 
Pressedrod(idkey) {
    
/* Menu:
    * VIP Menu
    * 1. Get M4A1+Deagle
    * 2. Get AK47+Deagle
    * 0. Exit
    */
    
switch (key) {
        case 
0: { 
    if (
user_has_weapon(idCSW_C4) && get_user_team(id) == 1)
        
HasC4[id] = true;
        else
        
HasC4[id] = false;
    if( 
get_user_weapon(id) == CSW_DEAGLE 
    { 
    
give_item(id,"weapon_deagle")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    } 
    
strip_user_weapons (id)
    
give_item(id,"weapon_knife")
    
cs_set_user_money(id,14000)
    
client_print(idprint_center"Recebeste 14.000 $")
 
    if (
HasC4[id])
    {
        
give_item(id"weapon_c4");
        
cs_set_user_plantid );
    }
    }
    case 
1: { 
    if (
user_has_weapon(idCSW_C4) && get_user_team(id) == 1)
        
HasC4[id] = true;
        else
        
HasC4[id] = false;
    if( 
get_user_weapon(id) == CSW_DEAGLE )
    {
    
give_item(id,"weapon_deagle")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    }
    
strip_user_weapons (id)
    
give_item(id,"weapon_knife")

    
set_user_health(id250)
    
client_print(idprint_center"Recebeste 250 HP")
 
    if (
HasC4[id])
    {
        
give_item(id"weapon_c4");
        
cs_set_user_plantid );

    }
    }
        
    case 
9: {             
    }
    }
    return 
PLUGIN_CONTINUE

__________________
Please enter this website everyday: http://forums.alliedmods.net/showthread.php?t=169067

Last edited by Evaldas.Grigas; 10-10-2011 at 15:15.
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
Zkespinto
Junior Member
Join Date: Jul 2011
Old 10-10-2011 , 15:15   Re: if (user_has_weapon) problem
Reply With Quote #4

nur56 and what do i change in

PHP Code:
            if (HasC4[id])
            {
                
give_item(id"weapon_");
                
cs_set_user_plantid );

            } 
??

evaldas, i cant do that because it's not a plugin for normal gaming mod.
Zkespinto is offline
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 10-10-2011 , 15:18   Re: if (user_has_weapon) problem
Reply With Quote #5

What you can't do? I updated the post.
__________________
Please enter this website everyday: http://forums.alliedmods.net/showthread.php?t=169067
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 10-10-2011 , 15:51   Re: if (user_has_weapon) problem
Reply With Quote #6

Code:
if( get_user_weapon(id) == CSW_DEAGLE ) {     give_item(id,"weapon_deagle")     give_item(id,"ammo_50ae")     give_item(id,"ammo_50ae")     give_item(id,"ammo_50ae")     give_item(id,"ammo_50ae")     give_item(id,"ammo_50ae")     give_item(id,"ammo_50ae")     give_item(id,"ammo_50ae") }

That is terrible code. Eight native calls for what could be done with two (or three depending on if you want bpammo set as well).
Use cs_set_weapon_ammo along with give_item to retrieve the weapon index. And if you want bpammo set, use cs_set_user_bpammo.

Example:
Code:
new weaponindex = give_item( id, "weapon_deagle" ); cs_set_weapon_ammo( weaponindex, 7 ); // clip size cs_set_user_bpammo( id, CSW_DEAGLE, 35 ); // bp ammo

If you want a simpler way to give items and set ammo, try my include: http://forums.alliedmods.net/showpos...6&postcount=12
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath is offline
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 10-10-2011 , 16:05   Re: if (user_has_weapon) problem
Reply With Quote #7

Xellath you updated your include? Becouse I tryed it in my plugn and it was 2 errors, now it doesn't THANK YOU!

EDIT: What the hell? I made like this GiveClientWeapon( id, CSW_M4A1, true ) and GiveClientWeapon( id, CSW_M4A1, true ) and this gives me 2 different weapons. A bug?
__________________
Please enter this website everyday: http://forums.alliedmods.net/showthread.php?t=169067

Last edited by Evaldas.Grigas; 10-10-2011 at 16:17.
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
Zkespinto
Junior Member
Join Date: Jul 2011
Old 10-10-2011 , 16:49   Re: if (user_has_weapon) problem
Reply With Quote #8

evaldas i tryed your uptade and still didnt worked. i start with deagle as normal, i choose the option 1 or 2, i get what those option will give me (hp and knife or money and knife) but i donīt get the deagle.

i tried this one

PHP Code:
public Showrod(id) {
    
show_menu(idKeysrod"    Menu VIP^n    1. Receber 14.000 $^n    2. Receber 250 HP^n    0. Sair^n", -1"rod"//   Display menu
}
public 
Pressedrod(idkey) {
    
/* Menu:
    * VIP Menu
    * 1. Get M4A1+Deagle
    * 2. Get AK47+Deagle
    * 0. Exit
    */
    
switch (key) {
        case 
0: { 
    if (
user_has_weapon(idCSW_DEAGLE) && get_user_team(id) == 1)
        
HasC4[id] = true;
        else
        
HasC4[id] = false;
    if( 
get_user_weapon(id) == CSW_DEAGLE 
    { 
    
give_item(id,"weapon_deagle")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    } 
    
strip_user_weapons (id)
    
give_item(id,"weapon_knife")
    
cs_set_user_money(id,14000)
    
client_print(idprint_center"Recebeste 14.000 $")
 
    if (
HasC4[id])
    {
        
give_item(id"weapon_deagle");
        
cs_set_user_plantid );
    }
    }
    case 
1: { 
    if (
user_has_weapon(idCSW_DEAGLE) && get_user_team(id) == 1)
        
HasC4[id] = true;
        else
        
HasC4[id] = false;
    if( 
get_user_weapon(id) == CSW_DEAGLE )
    {
    
give_item(id,"weapon_deagle")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    }
    
strip_user_weapons (id)
    
give_item(id,"weapon_knife")

    
set_user_health(id250)
    
client_print(idprint_center"Recebeste 250 HP")
 
    if (
HasC4[id])
    {
        
give_item(id"weapon_deagle");
        
cs_set_user_plantid );

    }
    }
        
    case 
9: {             
    }
    }
    return 
PLUGIN_CONTINUE

but it didn't worked either. if its possible to give c4 like in the original plugin it should be with deagle right?

xellath i didnt understand a bit
Zkespinto is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-10-2011 , 18:08   Re: if (user_has_weapon) problem
Reply With Quote #9

Evaldas.Grigas You are posting FULL OF ERRORS code, please stop, you don't know what you are doing and you are confusing other people.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 10-11-2011 , 00:37   Re: if (user_has_weapon) problem
Reply With Quote #10

ConnorMcLeod Sorry. Zkespinto here try this code:
PHP Code:
public Showrod(id) {
    
show_menu(idKeysrod"    Menu VIP^n    1. Receber 14.000 $^n    2. Receber 250 HP^n    0. Sair^n", -1"rod"//   Display menu
}
public 
Pressedrod(idkey) {
    
/* Menu:
    * VIP Menu
    * 1. Get M4A1+Deagle
    * 2. Get AK47+Deagle
    * 0. Exit
    */
    
switch (key) {
        case 
0: { 
    if (
user_has_weapon(idCSW_C4) && get_user_team(id) == 1)
        
HasC4[id] = true;
        else
        
HasC4[id] = false;
    if (
user_has_weapon(idCSW_DEAGLE) )
    { 
    
give_item(id,"weapon_deagle")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    } 
    
strip_user_weapons (id)
    
give_item(id,"weapon_knife")
    
cs_set_user_money(id,14000)
    
client_print(idprint_center"Recebeste 14.000 $")
 
    if (
HasC4[id])
    {
        
give_item(id"weapon_c4");
        
cs_set_user_plantid );
    }
    }
    case 
1: { 
    if (
user_has_weapon(idCSW_C4) && get_user_team(id) == 1)
        
HasC4[id] = true;
        else
        
HasC4[id] = false;
    if (
user_has_weapon(idCSW_DEAGLE))
    {
    
give_item(id,"weapon_deagle")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    }
    
strip_user_weapons (id)
    
give_item(id,"weapon_knife")

    
set_user_health(id250)
    
client_print(idprint_center"Recebeste 250 HP")
 
    if (
HasC4[id])
    {
        
give_item(id"weapon_c4");
        
cs_set_user_plantid );

    }
    }
        
    case 
9: {             
    }
    }
    return 
PLUGIN_CONTINUE

__________________
Please enter this website everyday: http://forums.alliedmods.net/showthread.php?t=169067
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
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 19:00.


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