AlliedModders

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

omgitsme 07-30-2010 09:31

Help
 
hey, i have some questions.
i read some tutorials, but i don't understand what this does?
public plugin_init[b]()]/b] the () in bold. what does it do? and how important is it?
and i saw in some plugins, they have ==
why two? :D
and then what does this mean? { and how important is it? thanks

drekes 07-30-2010 10:21

Re: questions
 
I never saw the bold ()

The == are to compare stuff.
PHP Code:

if(== b// compare them
{
    
b// assign them.


And {} is used to open and close a block of code, really important

omgitsme 07-30-2010 11:39

Re: questions
 
ok, thanks. and is there like a page where i can see how to give ammo? this dosen't work (for a deagle)
Code:

cs_set_user_bpammo( id, CSW_DEAGLE, 200);
edit: and how do you use client_print? i don't understand. i just made a silly /deagle plugin. and i want it to print "you got a deagle and 150hp"
Code:

#include <amxmodx>
#include <fun>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"
 
 
public plugin_init()
{
    register_clcmd("say /deagle", "weapon");
}
 
public weapon(id)
{
        if(is_user_alive(id))
    strip_user_weapons(id)
            give_item( id, "weapon_deagle" );
    set_user_health (id, 150)
    give_item( id, "weapon_knife" );
    client_print ("

and why when i compile it i get 2 errors? and whats the correct command for giving ammo? and what command is it when they respawn you give something? :D

drekes 07-30-2010 13:22

Re: Help
 
PHP Code:

#include <amxmodx>
#include <fun>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"
 
 
public plugin_init()
{
    
register_clcmd("say /deagle""weapon");
}
 
public 
weapon(id)
{
    if(
is_user_alive(id))
    {
        
strip_user_weapons(id)
        
give_itemid"weapon_knife" );
        
give_itemid"weapon_deagle" );
        
set_user_bpammo(idCSW_DEAGLE200);
        
set_user_health (id150);
        
        
client_print(idprint_chat"You got a deagle and 150 hp");
    }


You should read the basic tutorials first.

omgitsme 07-30-2010 13:38

Re: Help
 
ok. but how come this still dosen't work?
set_user_bpammo(id, CSW_DEAGLE, 200);
Error: Undefined symbol "set_user_bpammo" on line 21

lucas_7_94 07-30-2010 13:44

Re: Help
 
Add

- #include <cstrike>
- Change set_user_bpammo to cs_set_user_bpammo
- compile

#Drekes

+1

omgitsme 07-30-2010 15:03

Re: Help
 
thanks, and another last question (i hope)
i searched for spawn in the tutorials, and found a tutorial on new rounds, spawn and stuff. and i wanna know, how can i give a weapon/item to a player upon spawn?
Code:

#include <amxmodx>
#include <fun>
#include <cstrike>
#include <hamsandwich>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"
 
 
public plugin_init()
{
    register_clcmd("say /deagle", "weapon");
    RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1)
}
 
public weapon(id)
{
    if(is_user_alive(id))
    {
        strip_user_weapons(id)
        give_item( id, "weapon_knife" );
        give_item( id, "weapon_deagle" );
        cs_set_user_bpammo(id, CSW_DEAGLE, 200);
        set_user_health (id, 150);
        client_print(id, print_chat, "You got a deagle and 150 hp");
}

}
 
public fwHamPlayerSpawnPost(iPlayer) {
        if (is_user_alive(iPlayer)) {
    {
        give_item( id, "weapon_awp")
    }
}
{

i tried this, but it dosen't work. i'm just guessing, but i think it doesn't work because it's not a ham command and it's in the ham section? am i right? and i could'ent find the command for giving a item with ham. thanks for your help guys

Devil259 07-30-2010 15:08

Re: Help
 
PHP Code:

#include <amxmodx>
#include <fun>
#include <cstrike>
#include <hamsandwich>
 
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

public plugin_init()
{
     
register_clcmd("say /deagle""weapon");

     
RegisterHam(Ham_Spawn"player""fwHamPlayerSpawnPost"1)
}
 
public 
weapon(id)
{
     if(
is_user_alive(id))
     {
          
strip_user_weapons(id)
          
give_itemid"weapon_knife" );
          
give_itemid"weapon_deagle" );
          
cs_set_user_bpammo(idCSW_DEAGLE200);
          
set_user_health (id150);
          
client_print(idprint_chat"You got a deagle and 150 hp");
     }
}
 
public 
fwHamPlayerSpawnPost(id
{
     if (
is_user_alive(id))
          
give_itemid"weapon_awp")



drekes 07-31-2010 00:18

Re: Help
 
Quote:

Originally Posted by lucas_7_94 (Post 1256319)
Add

- #include <cstrike>
- Change set_user_bpammo to cs_set_user_bpammo
- compile

#Drekes

+1

Damn, i failed :oops:

omgitsme 08-03-2010 08:31

Re: Help
 
thanks, and what is wrong with this command
Code:

give_item(id, "weapon_he")
the whole code
Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <hamsandwich>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1)
}

public fwHamPlayerSpawnPost(id)
if (is_user_alive(id))
{
    if (get_user_flags(id) & ADMIN_CHAT)
    strip_user_weapons(id)
    give_item(id, "weapon_knife")
    give_item(id, "weapon_he")
    give_item(id, "weapon_sg")
    give_item(id, "weapon_fb")
    give_item(id, "weapon_fb")
}

it does strip the weapons, and i do get a knife, and a bomb. but no grenades. wrong code, right? :D


All times are GMT -4. The time now is 00:08.

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