Raised This Month: $ Target: $400
 0% 

1st plugin -> help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lagayo
Junior Member
Join Date: Mar 2012
Old 03-06-2013 , 07:38   1st plugin -> help
Reply With Quote #1

well, im learning c++ on school , almost 1 year of c++ programming, i ever wanted to make my own cs plugins, now that i know a programming language i think i can learn pawn, but i need some help to start, i already read lots of tutorials, and im trying to make my first plugin.

thats what i got so far:
PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "give_he"
#define VERSION "1.0"
#define AUTHOR "Lagayo"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_concmd("amx_givehe","cmd_givehe"ADMIN_BAN,"<target>")
}


public 
cmd_givehe(id,level,cid)
{
    if (!
cmd_access(idlevelcid3))
        return 
PLUGIN_HANDLED

so got stuck on coding the comand(the hardest part and the one you need to learn some skills)
so im asking if anyone can finish this plugin, comenting EVERY line so i can understand it better ;)

Thank you
lagayo is offline
wangbochiang
Member
Join Date: Aug 2006
Location: Taiwan - Taichung
Old 03-06-2013 , 08:55   Re: 1st plugin -> help
Reply With Quote #2

you may search in forum,
I found a post just have likely question as you
https://forums.alliedmods.net/showthread.php?t=90236

try this see if it helps
__________________
Catch me on : @twitter

Last edited by wangbochiang; 03-06-2013 at 08:55.
wangbochiang is offline
Send a message via MSN to wangbochiang Send a message via Yahoo to wangbochiang Send a message via Skype™ to wangbochiang
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 03-06-2013 , 08:58   Re: 1st plugin -> help
Reply With Quote #3

Code:
#include <amxmodx> #include <amxmisc> #include <fun> //fun module has the give_item native #define PLUGIN "give_he" #define VERSION "1.0" #define AUTHOR "Lagayo" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)           register_concmd("amx_givehe","cmd_givehe", ADMIN_BAN,"<target>") } public cmd_givehe(id,level,cid) {     if (!cmd_access(id, level, cid, 3))         return PLUGIN_HANDLED     new iPlayer, szTarget[16] //create an int for target id and array for target string     read_argv(1, szTarget, charsmax(szTarget)) //read first arg from command and store it in szTarget     iPlayer = cmd_target(id, szTarget, CMDTARGET_ALLOW_SELF | CMDTARGET_NO_BOTS) //use cmd_target stock to get the target id     if (is_user_alive(iPlayer)) //this to check if cmd_target was successful and if the player is alive         give_item(iPlayer, "weapon_hegrenade") //give iPlayer a "weapon_hegrenade"     return PLUGIN_HANDLED //you should return this in the end of concmd so you wont get the invalid command error }

Last edited by jimaway; 03-06-2013 at 14:57.
jimaway is offline
Old 03-06-2013, 10:28
Kard1nal
This message has been deleted by Kard1nal.
Alekkkk
Member
Join Date: Mar 2012
Location: Bulgaria
Old 03-06-2013 , 10:53   Re: 1st plugin -> help
Reply With Quote #4

lol guys , look at his code , he want to give grenade not to the person who use the command but to a target player..

you can look at this post https://forums.alliedmods.net/showpo...68&postcount=3
__________________
Alekkkk is offline
Send a message via Skype™ to Alekkkk
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 03-06-2013 , 14:54   Re: 1st plugin -> help
Reply With Quote #5

yeah my bad lol
fixed now
jimaway is offline
guipatinador
SourceMod Donner Party
Join Date: Oct 2009
Location: Poortugal
Old 03-06-2013 , 16:30   Re: 1st plugin -> help
Reply With Quote #6

PHP Code:
if (!cmd_access(idlevelcid3)) 
2 arguments instead of 3.
guipatinador is offline
lagayo
Junior Member
Join Date: Mar 2012
Old 03-06-2013 , 18:11   Re: 1st plugin -> help
Reply With Quote #7

Quote:
Originally Posted by jimaway View Post
Code:
#include <amxmodx> #include <amxmisc> #include <fun> //fun module has the give_item native #define PLUGIN "give_he" #define VERSION "1.0" #define AUTHOR "Lagayo" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)           register_concmd("amx_givehe","cmd_givehe", ADMIN_BAN,"<target>") } public cmd_givehe(id,level,cid) {     if (!cmd_access(id, level, cid, 3))         return PLUGIN_HANDLED     new iPlayer, szTarget[16] //create an int for target id and array for target string     read_argv(1, szTarget, charsmax(szTarget)) //read first arg from command and store it in szTarget     iPlayer = cmd_target(id, szTarget, CMDTARGET_ALLOW_SELF | CMDTARGET_NO_BOTS) //use cmd_target stock to get the target id     if (is_user_alive(iPlayer)) //this to check if cmd_target was successful and if the player is alive         give_item(iPlayer, "weapon_hegrenade") //give iPlayer a "weapon_hegrenade"     return PLUGIN_HANDLED //you should return this in the end of concmd so you wont get the invalid command error }
it gives error on this line

PHP Code:
      give_item(iPlayer"weapon_hegrenade"//give iPlayer a "weapon_hegrenade" 
EDIT: Nvm i forgot to include <fun>.

But i got 2 warnings, any1 know why?

Last edited by lagayo; 03-06-2013 at 18:23.
lagayo is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-06-2013 , 18:39   Re: 1st plugin -> help
Reply With Quote #8

PHP Code:
#include <amxmodx>

#include <amxmisc> // stocks

// modules
#include <hamsandwich> // ExecuteHamB
#include <fun> // give_item

#define PLUGIN ""
#define VERSION "0.0.1"

public plugin_init()
{
    
register_pluginPLUGINVERSION"ConnorMcLeod" )

    
register_concmd("amx_give_he""ConCmd_GiveHe"ADMIN_BAN"<#userid/partial_name/steamid>")
}

public 
ConCmd_GiveHeid lvlcmd )
{
    if( 
cmd_access(idlvlcmd/* 2 args required */ ) )
    {
        new 
szTarget[32], iTarget // <- name can be 32 letters
        
read_argv(1szTargetcharsmax(szTarget))

        
// #define CMDTARGET_OBEY_IMMUNITY (1<<0)
        // #define CMDTARGET_ALLOW_SELF    (1<<1)
        // #define CMDTARGET_ONLY_ALIVE    (1<<2)
        // #define CMDTARGET_NO_BOTS        (1<<3)
        // those defines inside amxmisc.inc
        
iTarget cmd_target(idszTargetCMDTARGET_ALLOW_SELF CMDTARGET_ONLY_ALIVE// allow self (compares to 'id) and restrict to alive players...

        
if( iTarget // bolean check
        
{
            
// then your specific code
            
if( !user_has_weapon(iTargetCSW_HEGRENADE) )
            {
                
give_item(iTarget"weapon_hegrenade")
            }
            else
            {
                
ExecuteHamB(Ham_GiveAmmoiTarget1"HEGrenade"999)
            }
        }
    }
    return 
PLUGIN_HANDLED // so engine doesn't send the command to dll and you don't get "Unknown command" in your console.

About differences between pawn and C++, you can read pawn tutorial : http://www.compuphase.com/pawn/Pawn_Language_Guide.pdf
On page : Pitfalls: differences from C.... ..... ..... ..... .... ..... ..... ...133
This tutorial is pawn generic, not amxx but you can still get some usefull information in it.

Here you can get usefull tutorials : https://forums.alliedmods.net/showthread.php?t=172936

See the part about optimizing plugins : http://wiki.amxmodx.org/Optimizing_P...X_Scripting%29
( pawn compiler is different from C )

Good luck.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 03-07-2013 at 12:26.
ConnorMcLeod is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 03-07-2013 , 09:26   Re: 1st plugin -> help
Reply With Quote #9

ConnorMcLeod you made the same mistake that i did originally, giving the grenade to id instead of iTarget

Last edited by jimaway; 03-07-2013 at 09:26.
jimaway is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-07-2013 , 12:26   Re: 1st plugin -> help
Reply With Quote #10

I don't know what you mean.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Reply


Thread Tools
Display Modes

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 21:47.


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