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-15-2007 , 00:33   Scout Sniper Only
Reply With Quote #1

Hello, i made this topic if someone of the AMXX scripters her can look in the below code and tell me if the scripts have any faults. The plugin is working as it should be but actualy i don't know what i have done and just copied parts of other plugins. The only thing i'm not sure of if all the ";" signs are needed what i writed.

Code:
#include <amxmodx>

public plugin_init() 
{
    register_plugin("Scout Sniper Only", "1.0", "sharpe.nl");
    register_clcmd("awp", "cmd_awp");
    register_clcmd("sg550", "cmd_sg550");
    register_clcmd(" g3sg1", "cmd_g3sg1")
} 

public cmd_awp(id) 
{
    client_cmd(id, "scout")
    return PLUGIN_HANDLED; 
}

public cmd_sg550(id) 
{
    client_cmd(id, "scout")
    return PLUGIN_HANDLED; 
}

public cmd_ g3sg1(id) 
{
    client_cmd(id, "scout")
    return PLUGIN_HANDLED; 
}
__________________
Luck? Luck is only one feeling of amazement concerning a seemingly incidental circumstance which one himself must create.

Last edited by Maurice; 11-15-2007 at 00:37.
Maurice is offline
M249-M4A1
I <3 Mac
Join Date: May 2005
Location: Not interested
Old 11-15-2007 , 00:38   Re: Scout Sniper Only
Reply With Quote #2

Semicolons are optional - but it looks good, as it denontes the end of a statement

As for your code, you can make it as simple as this.

PHP Code:
#include <amxmodx>

public plugin_init() 
{
    
register_plugin("Scout Sniper Only""1.0""sharpe.nl")
    
register_clcmd("awp""cmd_scout")
    
register_clcmd("sg550""cmd_scout")
    
register_clcmd("g3sg1""cmd_scout")


public 
cmd_scout(id
{
    
client_cmd(id"scout")
    return 
PLUGIN_HANDLED

Because all the other rifles point to the same code, you can make it execute 1 procedure, instead of 3 identical ones
__________________

Last edited by M249-M4A1; 11-15-2007 at 00:41.
M249-M4A1 is offline
Maurice
Senior Member
Join Date: Nov 2006
Location: Netherlands
Old 11-15-2007 , 01:11   Re: Scout Sniper Only
Reply With Quote #3

Thanks for the help M249-M4A1! If i would change the given gun on a later time would the below code be correct to?

Code:
#include <amxmodx>

public plugin_init()  
{
    register_plugin("Scout Sniper Only", "1.0", "sharpe.nl")
    register_clcmd("awp", "cmd_scout")
    register_clcmd("sg550", "cmd_sg550")
    register_clcmd("g3sg1", "cmd_g3sg1")
}  

public cmd_scout(id)  
{
    client_cmd(id, "scout")
    return PLUGIN_HANDLED
}

public cmd_sg550(id)  
{
    client_cmd(id, "tmp")
    return PLUGIN_HANDLED
}  

public cmd_g3sg1(id)  
{
    client_cmd(id, "mac10")
    return PLUGIN_HANDLED
}
__________________
Luck? Luck is only one feeling of amazement concerning a seemingly incidental circumstance which one himself must create.

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

Have a look at this plugin : http://forums.alliedmods.net/showthread.php?p=18295
ConnorMcLeod is offline
Maurice
Senior Member
Join Date: Nov 2006
Location: Netherlands
Old 11-15-2007 , 08:43   Re: Scout Sniper Only
Reply With Quote #5

Thanks for the idea connorr but honestly said the script code what i writed wasn't meant to change all snipers in scout's. I used that only as test and want to change commands like cl_rebuy, rebuy and some others. I know there is also a nice command restricter plugin from SubStream but i preffer i small simply plugin and that i can give any command a new function. Can anybody confirm if the 2nd script code is correct?
__________________
Luck? Luck is only one feeling of amazement concerning a seemingly incidental circumstance which one himself must create.
Maurice is offline
M249-M4A1
I <3 Mac
Join Date: May 2005
Location: Not interested
Old 11-15-2007 , 23:19   Re: Scout Sniper Only
Reply With Quote #6

Referring to your post about other guns, yes that would be fine. The only problem I can see right now is that they are changing to a weapon they don't have. My only suggestion is to make them drop the weapon-to-be-switched-out and give them the new weapon (and maybe subtract money to avoid weapon spamming)

EDIT: I haven't played CS in ages. Is the weapon name mean BUY the weapon or USE the weapon?
__________________

Last edited by M249-M4A1; 11-15-2007 at 23:21.
M249-M4A1 is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 11-16-2007 , 08:53   Re: Scout Sniper Only
Reply With Quote #7

Buy.

I think you give the weapon's classname to use it.

so

scout

To buy one, and

weapon_scout

To use it.

(I could be wrong there, though ;-) )
purple_pixie is offline
Maurice
Senior Member
Join Date: Nov 2006
Location: Netherlands
Old 11-17-2007 , 00:42   Re: Scout Sniper Only
Reply With Quote #8

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 #9

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 #10

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
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