Raised This Month: $ Target: $400
 0% 

Hello, new to writing fresh code.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ecko1988
New Member
Join Date: Jun 2006
Old 10-18-2006 , 04:12   Hello, new to writing fresh code.
Reply With Quote #1

I have been tinkering with Code for ages, but never really writing up code of my own. This is my first attempt, but i'm not sure what i've done wrong. Could somone just proof check it for me.

Code:
#include <amxmodx> #include <amxmisc> #include <engine> #include <engine_stocks> #include <fun> #include <harbu> new id new isonapill[33] public plugin_init() {         register_plugin("Adrenaline pills","0.0.0.0","Dean Booker AKA Ecko Mantle");         register_srvcmd("item_apill","item_apill"); } public item_apill() {         if(isonapill[id] = 1)         {                return PLUGIN_HANDLED         }         else         {         set_user_maxspeed 450         client_cmd(id, "cl_forwardspeed 450.0")         client_cmd(id, "cl_sidespeed 450.0")         client_cmd(id, "cl_backspeed 450.0")         client_cmd(id, "say /me takes an Adrenaline Pill.")         client_cmd(id, print_chat, "[Umbrella] You take an Adrenaline Pill.")         client_cmd(set_task(30.0, "apill_end", id)         isonapill[id] = 1         return PLUGIN_HANDLED; } public apill_end() {         set_user_maxspeed 350         client_cmd(id, "cl_forwardspeed 350.0")         client_cmd(id, "cl_sidespeed 350.0")         client_cmd(id, "cl_backspeed 350.0")         isonapill[id] = 0         return PLUGIN_HANDLED }


Any pointers would be great!

Regards,
Ecko
ecko1988 is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 10-18-2006 , 04:30   Re: Hello, new to writing fresh code.
Reply With Quote #2

you need to compile it , then you will find many many many mistakes.
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 10-18-2006 , 09:27   Re: Hello, new to writing fresh code.
Reply With Quote #3

heres one that should work (compare the 2)
Code:
#include <amxmodx> //only include things your using #include <fun> #define MAX_PLAYERS 32 //we dont need to make id global new isonapill[33] public plugin_init() {         register_plugin("Adrenaline pills","0.0.0.0","Dean Booker AKA Ecko Mantle");         //register it as a console command so we can get the id properly         register_concmd("item_apill","item_apill",ADMIN_ALL)         //register it again for admins that want to set it to everyone         register_concmd("item_apill_all","item_apill_all",ADMIN_KICK) } public item_apill_all(id) {         for(new i=1; i<MAX_PLAYERS; i++) //there is a better way to get players, but im in a hurry         {              if(is_user_connected(i))                  item_apill(i)         } } public item_apill(id)//we get the id here {         if(isonapill[id] = 1 || 1>id>MAX_PLAYERS)//stop if it isnt a proper id (a different ent or the server console), note that MAX_PLAYERS is defined at the top         {                return PLUGIN_HANDLED         }         if(is_user_alive(id)) //can only set maxspeed on alive people               set_user_maxspeed(id,450.0)         client_cmd(id, "cl_forwardspeed 450.0")         client_cmd(id, "cl_sidespeed 450.0")         client_cmd(id, "cl_backspeed 450.0")         client_cmd(id, "say /me takes an Adrenaline Pill.")         client_cmd(id, print_chat, "[Umbrella] You take an Adrenaline Pill.")         set_task(30.0, "apill_end", id)//your passing the id         isonapill[id] = 1         return PLUGIN_HANDLED; } public apill_end(id)//we passed the id, so lets keep it {         if(is_user_alive(id)) //again only alive people              set_user_maxspeed(id, 350.0)         client_cmd(id, "cl_forwardspeed 350.0")         client_cmd(id, "cl_sidespeed 350.0")         client_cmd(id, "cl_backspeed 350.0")         isonapill[id] = 0         return PLUGIN_HANDLED }

Last edited by Emp`; 10-18-2006 at 20:15.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
jim_yang
Veteran Member
Join Date: Aug 2006
Old 10-18-2006 , 09:54   Re: Hello, new to writing fresh code.
Reply With Quote #4

Quote:
client_cmd(id, print_chat, "[Umbrella] You take an Adrenaline Pill.")
client_cmd(set_task(30.0, "apill_end", id)//your passing the id
are you kidding?
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>

Last edited by jim_yang; 10-18-2006 at 09:57.
jim_yang is offline
schnitzelmaker
Senior Member
Join Date: Apr 2006
Location: HERE
Old 10-18-2006 , 10:50   Re: Hello, new to writing fresh code.
Reply With Quote #5

Code:
client_print(id, print_chat, "[Umbrella] You take an Adrenaline Pill.") set_task(30.0, "apill_end", id)//your passing the id
__________________
schnitzelmaker is offline
wonsae
Senior Member
Join Date: Jan 2006
Location: Behind you >:D
Old 10-18-2006 , 10:53   Re: Hello, new to writing fresh code.
Reply With Quote #6

PHP Code:
#include <amxmodx>
#include <fun>
new isonapill[33]
public 
plugin_init()
{
        
register_plugin("Adrenaline pills","0.0.0.0","Dean Booker AKA Ecko Mantle");
        
register_srvcmd("item_apill","item_apill");
}
public 
item_apill()
{
 new 
arg[32], id
 read_argv
(1,arg,32)
 
id str_to_num(arg)
        if(
isonapill[id] = 1)
        {
               return 
PLUGIN_HANDLED
        
}
        else
        {
         
set_user_maxspeed(id450.0)
         
client_cmd(id"cl_forwardspeed 450.0")
         
client_cmd(id"cl_sidespeed 450.0")
         
client_cmd(id"cl_backspeed 450.0")
         
client_cmd(id"say /me takes an Adrenaline Pill.")
         
client_print(idprint_chat"[Umbrella] You take an Adrenaline Pill.")
         
set_task(30.0"apill_end"id)
         
isonapill[id] = 1
 
}
        return 
PLUGIN_HANDLED;
}
public 
apill_end(id)
{
        
set_user_maxspeed(id320.0)
        
client_cmd(id"cl_forwardspeed 320.0")
        
client_cmd(id"cl_sidespeed 320.0")
        
client_cmd(id"cl_backspeed 320.0")
        
isonapill[id] = 0
        
return PLUGIN_HANDLED

I'm guessing it's for TSRP.
wonsae is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 10-18-2006 , 12:03   Re: Hello, new to writing fresh code.
Reply With Quote #7

Quote:
Originally Posted by jim_yang View Post
are you kidding?
Nothing is really wrong, I'm assuming he is new. The only problem he is having is dealing with concepts, which everybody does when they begin.

Some things:
  • Try to understand what functions are, how they are executed, and how they work.
  • Know how parameters are passed to functions, and what they are.
  • Functions cannot be executed on clients, commands can though.
  • That's all, just some quick points.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
ecko1988
New Member
Join Date: Jun 2006
Old 10-18-2006 , 20:13   Re: Hello, new to writing fresh code.
Reply With Quote #8

Thanks, i'll look into the bits on more detail that i was lacking.
ecko1988 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 04:51.


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