AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Scout Sniper Only (https://forums.alliedmods.net/showthread.php?t=63211)

Maurice 11-15-2007 00:33

Scout Sniper Only
 
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;
}


M249-M4A1 11-15-2007 00:38

Re: Scout Sniper Only
 
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

Maurice 11-15-2007 01:11

Re: Scout Sniper Only
 
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
}


ConnorMcLeod 11-15-2007 05:57

Re: Scout Sniper Only
 
Have a look at this plugin : http://forums.alliedmods.net/showthread.php?p=18295

Maurice 11-15-2007 08:43

Re: Scout Sniper Only
 
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?

M249-M4A1 11-15-2007 23:19

Re: Scout Sniper Only
 
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?

purple_pixie 11-16-2007 08:53

Re: Scout Sniper Only
 
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 ;-) )

Maurice 11-17-2007 00:42

Re: Scout Sniper Only
 
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;
}


M249-M4A1 11-17-2007 02:13

Re: Scout Sniper Only
 
For the line in red, do get_user_weapon, not get_user_weapons

ConnorMcLeod 11-17-2007 02:19

Re: Scout Sniper Only
 
Quote:

Originally Posted by M249-M4A1 (Post 553738)
For the line in red, do get_user_weapon, not get_user_weapons

Won't return true if players has not this weapon in his hands.




Just replace :
if(get_user_weapons(id) == CSW_AK47){

with

if( check_ak47( id ) ) {



Note that check_ak47( id ) doen't need to be public.


All times are GMT -4. The time now is 01:19.

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