AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   weapon ammo (https://forums.alliedmods.net/showthread.php?t=163151)

LightScribe16 07-27-2011 07:59

weapon ammo
 
In some maps give ammunition scout, Please help fix this problem!

PHP Code:

public give_stuff(id)
{
if(!
is_user_alive(id)) return PLUGIN_HANDLED
 
    else if(
get_user_flags(id) & ADMIN_LEVEL_H)
    {
    
   
fm_give_item(id"item_assaultsuit");
   
fm_give_item(id"weapon_flashbang");
   
fm_give_item(id"weapon_flashbang");
   
fm_give_item(id"weapon_hegrenade");
   
fm_give_item(id"weapon_smokegrenade");
   
set_user_gravity (id0.75);
   
cs_set_weapon_ammo(fm_give_itemid"weapon_scout" ), 0);
   
cs_set_user_bpammo(idCSW_SCOUT0);
   
   return 
PLUGIN_CONTINUE
         
}
    



Aykay 07-27-2011 08:04

Re: weapon ammo
 
How are you calling give_stuff(id)?

Maybe you should put it in the CurWeapon event?

wrecked_ 07-27-2011 08:11

Re: weapon ammo
 
What's wrong with give_item()?

LightScribe16 07-27-2011 08:19

Re: weapon ammo
 
Quote:

Originally Posted by Aykay (Post 1519575)
How are you calling give_stuff(id)?

Maybe you should put it in the CurWeapon event?

PHP Code:

RegisterHam(Ham_Spawn"player""give_stuff"1

Quote:

What's wrong with give_item()?
When someone die, grenades return, but with fm give item not so

Sorry for my bad language

Full code

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>
#include <cstrike>
#include <amxmisc>
#include <fun>

#define PLUGIN_NAME "vipas"
#define PLUGIN_AUTHOR "Kukulis"
#define PLUGIN_VERSION "0.1"

static const COLOR[] = "^x04"
static const CONTACT[] = ""

new maxplayers
new gmsgSayText
new bool:HasC4[33]
#define Keysrod (1<<0)|(1<<1)|(1<<9) // Keys: 1234567890

public plugin_init()
{
register_plugin(PLUGIN_NAMEPLUGIN_AUTHORPLUGIN_VERSION);

RegisterHam(Ham_Spawn"player""give_stuff"1)     
register_event("ResetHUD","event_reset_hud","be");
register_event"ResetHUD""ResetHUD""be" )
register_clcmd("say /vip","admin_motd",0,"- Shows the MOTD.")

register_clcmd("say""handle_say")
register_cvar("amx_contactinfo"CONTACTFCVAR_SERVER)
gmsgSayText get_user_msgid("SayText")

maxplayers get_maxplayers()

return 
PLUGIN_CONTINUE

}



public 
event_reset_hud(id)
{
if(!
is_user_connected(id))
return 
PLUGIN_CONTINUE;

client_print(idprint_chat"[VIP] Write /vip To see the VIP privileges.")

if(!
access(id,ADMIN_CVAR))
return 
PLUGIN_CONTINUE;

set_task(1.0,"give_stuff",id);

return 
PLUGIN_CONTINUE;
}

public 
admin_motd(id,level,cid) {

    if (!
cmd_access(id,level,cid,1))
    return 
PLUGIN_CONTINUE
    
    show_motd
(id,"vip.txt","VIP by Kukulis")
    return 
PLUGIN_CONTINUE   
}




public 
give_stuff(id)
{
if(!
is_user_alive(id)) return PLUGIN_HANDLED
 
    else if(
get_user_flags(id) & ADMIN_LEVEL_H)
    {
    
   
fm_give_item(id"item_assaultsuit");
   
fm_give_item(id"weapon_flashbang");
   
fm_give_item(id"weapon_flashbang");
   
fm_give_item(id"weapon_hegrenade");
   
fm_give_item(id"weapon_smokegrenade");
   
set_user_gravity (id0.75);
   
cs_set_weapon_ammo(fm_give_itemid"weapon_scout" ), 0);
   
cs_set_user_bpammo(idCSW_SCOUT0);
   
   return 
PLUGIN_CONTINUE
         
}
    
}

public 
handle_say(id)
{
    new 
said[192]
    
read_args(said,192)
    if(( 
containi(said"who") != -&& containi(said"admin") != -1) || contain(said"/vips") != -1)
        
set_task(0.1,"print_viplist"id)
    return 
PLUGIN_CONTINUE
}

public 
print_viplist(user
{
    new 
adminnames[33][32]
    new 
message[256]
    new 
contactinfo[256], contact[112]
    new 
idcountxlen
    
    
for(id id <= maxplayers id++)
        if(
is_user_connected(id))
            if(
get_user_flags(id) & ADMIN_CVAR)
                
get_user_name(idadminnames[count++], 31)

    
len format(message255"%s Online VIP: ",COLOR)
    if(
count 0) {
        for(
count x++) {
            
len += format(message[len], 255-len"%s%s "adminnames[x], < (count-1) ? ", ":"")
            if(
len 96 ) {
                
print_message(usermessage)
                
len format(message255"%s ",COLOR)
            }
        }
        
print_message(usermessage)
    }
    else {
        
len += format(message[len], 255-len"No online VIP.")
        
print_message(usermessage)
    }

    
get_cvar_string("amx_contactinfo"contact63)
    if(
contact[0])  {
        
format(contactinfo111"%s Contact Server Admin -- %s"COLORcontact)
        
print_message(usercontactinfo)
    }
}

print_message(idmsg[])
{
    
message_begin(MSG_ONEgmsgSayText, {0,0,0}, id)
    
write_byte(id)
    
write_string(msg)
    
message_end()
}

public 
ResetHUDid )
{
    
set_task0.5"VIP"id 6910 )

    if (
user_has_weapon(idCSW_C4) && get_user_team(id) == 1)
        {
            
HasC4[id] = true;
            
set_task0.5"Bomb"id 6910 )
        }
}

public 
VIPTaskIDid )
{
    new 
id TaskID 6910

    
if ( get_user_flagsid ) & ADMIN_LEVEL_H 
    {
        
message_beginMSG_ALLget_user_msgid"ScoreAttrib" ) )
        
write_byteid )
        
write_byte)
        
message_end( )
    }

    return 
PLUGIN_HANDLED



SnoW 07-28-2011 07:48

Re: weapon ammo
 
Could you specify what was the problem again?

LightScribe16 07-28-2011 08:43

Re: weapon ammo
 
When starting a new round then given a scout with 10 / 0 , but I need to give a scout with 0/0 ammunition

SnoW 07-28-2011 09:07

Re: weapon ammo
 
Quote:

Originally Posted by LightScribe16 (Post 1520305)
When starting a new round then given a scout with 10 / 0 , but I need to give a scout with 0/0 ammunition

Code:
cs_set_weapon_ammo(fm_give_item( id, "weapon_scout" ), 0);
This is exactly what you want. You have to though use the newest version of everything, not have some other plugin giving ammo and actually replace/update the copy of this same plugin that did not empty the ammo.

usaexelent 07-28-2011 09:20

Re: weapon ammo
 
It's hard for Lithuania people to script :D

Exolent[jNr] 07-28-2011 10:02

Re: weapon ammo
 
Quote:

Originally Posted by LightScribe16 (Post 1520170)
UP Up

Don't bump until 2 weeks have passed since last post.

LightScribe16 07-29-2011 08:17

Re: weapon ammo
 
WTF!? When i compile plugin are error
Quote:

warning 209 : function "give_stuff" should return a value
With bold is marked place where is error

Quote:

public give_stuff(id)
{
if(!
is_user_alive(id)) return PLUGIN_HANDLED;

else if(
get_user_flags(id) & ADMIN_LEVEL_H)
{

fm_give_item(id, "item_assaultsuit");
fm_give_item(id, "weapon_flashbang");
fm_give_item(id, "weapon_flashbang");
fm_give_item(id, "weapon_hegrenade");
fm_give_item(id, "weapon_smokegrenade");
set_user_gravity (id, 0.75);
cs_set_weapon_ammo(fm_give_item( id, "weapon_scout" ), 0);
cs_set_user_bpammo(id, CSW_SCOUT, 0);

return
PLUGIN_CONTINUE
}

}



All times are GMT -4. The time now is 11:57.

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