Raised This Month: $ Target: $400
 0% 

Scout Sniper Only


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Maurice
Senior Member
Join Date: Nov 2006
Location: Netherlands
Old 11-17-2007 , 00:42   Re: Scout Sniper Only
Reply With Quote #1

I'm getting away off topic now but can enybody help me with the red line in the below mentioned script. Honestly said i'm doing something that maybe make no sense because i just grabbed parts of script and placed it into one script.

Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

public plugin_init() {
    register_plugin("Buy Weapons", "1.0", "")
    register_clcmd("ak47", "buy_ak47")
    register_clcmd("buytest", "buy_ak47")
}

public buy_ak47(id) {
    if(!cs_get_user_buyzone(id) || !is_user_alive(id)) {
        return PLUGIN_HANDLED
        }
    if(get_user_weapons(id) == CSW_AK47){
        client_print(id,print_center,"You already own that weapon.")
        return PLUGIN_HANDLED
        }
    if(cs_get_user_money(id) < 2500){
        client_print(id,print_center,"You have insufficient funds!")
        return PLUGIN_HANDLED
        }
    cs_set_user_money(id,(cs_get_user_money(id) - 2500))
    drop_prim(id)
    give_item(id, "weapon_ak47")
//  cs_set_user_bpammo(id, CSW_AK47, 90)
    return PLUGIN_HANDLED
}

public drop_prim(id){
    engclient_cmd(id, "drop", "weapon_shield")
    engclient_cmd(id, "drop", "weapon_m3")
    engclient_cmd(id, "drop", "weapon_xm1014")
    engclient_cmd(id, "drop", "weapon_mp5navy")    
    engclient_cmd(id, "drop", "weapon_p90")
    engclient_cmd(id, "drop", "weapon_mac10")
    engclient_cmd(id, "drop", "weapon_tmp")
    engclient_cmd(id, "drop", "weapon_ump45")
    engclient_cmd(id, "drop", "weapon_galil")
    engclient_cmd(id, "drop", "weapon_famas")    
    engclient_cmd(id, "drop", "weapon_m4a1")
    engclient_cmd(id, "drop", "weapon_aug")
    engclient_cmd(id, "drop", "weapon_ak47")
    engclient_cmd(id, "drop", "weapon_sg552")
    engclient_cmd(id, "drop", "weapon_scout")
    engclient_cmd(id, "drop", "weapon_awp")
    engclient_cmd(id, "drop", "weapon_sg550")
    engclient_cmd(id, "drop", "weapon_g3sg1")
    engclient_cmd(id, "drop", "weapon_m249")
}
Proberly the red line is a complete wrong line and maybe the below scrip part would be a better idea but i just don't know how to build it into the script.

Code:
public bool:check_ak47( id ) {

    new iWeapons[32];
    new iTotalWeapons = 0;
    get_user_weapons( id, iWeapons, iTotalWeapons );

    for ( new i = 0; i < iTotalWeapons; i++ )
    {
        switch ( iWeapons[i] )
        {
            case CSW_AK47:    return true;

        }
    }
    return false;
}
__________________
Luck? Luck is only one feeling of amazement concerning a seemingly incidental circumstance which one himself must create.

Last edited by Maurice; 11-17-2007 at 00:45.
Maurice is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-17-2007 , 02:57   Re: Scout Sniper Only
Reply With Quote #2

Quote:
Originally Posted by Maurice View Post
Code:
bool:check_ak47( id ) {

    new iWeapons[32];
    new iTotalWeapons = 0;
    get_user_weapons( id, iWeapons, iTotalWeapons );

    for ( new i = 0; i < iTotalWeapons; i++ )
    {
        switch ( iWeapons[i] )
        {
            case CSW_AK47:    return true;

        }
    }
    return false;
}
Of course you have to let this code anywhere in your script.

Also you can simply use user_has_weapon native

if ( user_has_weapon(id , CSW_AK47) ) {

http://www.amxmodx.org/funcwiki.php?go=func&id=155

Last edited by ConnorMcLeod; 11-17-2007 at 03:00.
ConnorMcLeod is offline
Maurice
Senior Member
Join Date: Nov 2006
Location: Netherlands
Old 11-17-2007 , 04:43   Re: Scout Sniper Only
Reply With Quote #3

Quote:
Originally Posted by connorr View Post
Also you can simply use user_has_weapon native

if ( user_has_weapon(id , CSW_AK47) ) {
Thanks connorr, This works flawlessly! Now i only have to add a feature that maintains the allowed buytime of 20 seconds. I was wondering if i can do this the best with the below mentioned script that i found in another plugin but again there is a line (red colored) i dont know if it is correct, actually i don't understand the line.

Code:
new bool:BuyTime = false

public plugin_init() {
    register_event("ResetHUD","new_round","b")

public buy_ak47(id) {
        if (!BuyTime) {
        client_print(id,print_center,"20 seconds have passed. You can't buy anything now!")
        return PLUGIN_HANDLED
        }

public new_round(id) {
        new params[0] = 0
        set_task(20, "buy_over", 0, params, 0, "a", 1)
        BuyTime = true    
        }

public buy_over(id) {
        BuyTime = false
        }
__________________
Luck? Luck is only one feeling of amazement concerning a seemingly incidental circumstance which one himself must create.

Last edited by Maurice; 11-17-2007 at 04:49.
Maurice is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-17-2007 , 05:08   Re: Scout Sniper Only
Reply With Quote #4

I don't know if cs_get_user_buyzone return 1 when buytime is over but you can try it.

cstrike :

if( !cs_get_user_buyzone(id) )
return

fakemeta :

if( !__cs_get_user_buyzone(id) )
return

Code:
#define OFFSET_MAPZONE      235 #define PLAYER_IN_BUYZONE   (1<<0) __cs_get_user_buyzone(id) {     if ( get_pdata_int(id, OFFSET_MAPZONE) & PLAYER_IN_BUYZONE )         return 1     return 0 }
ConnorMcLeod 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 01:19.


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