Raised This Month: $32 Target: $400
 8% 

A Simple Tutorial


Post New Thread Closed Thread   
 
Thread Tools Display Modes
Author Message
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 12-24-2004 , 12:59   A Simple Tutorial
#1

Hello, I'm Dizzy. When I Started Scripting I Thought It Was Hard Like Most People Do. I Know How You Feel. I Made This Simple Tutorial To Get People Like You Who Don't Know How To Script To Learn it Easier.

LOANER: One Of Dizzy's Plugins:
Code:
//This is A Comment... If You Place // Before A Line It Is Not Compiled Into The Plugin /*This is Another Type Of Comment You Can Type As Many Lines As You Want Until You Place This*/ #include <amxmodx>  //This Is An Include. It includes The Mods You Want (Modules Also) #include <fun> //This is A Module. The Fun Module It is included in this plugin #include <cstrike> //This is the Module That makes this plugin for CS (Or has something needed) new bool:hasloaned[32] //new bool: (as in a new phrase) hasloaned (The Phrase) [32] (An Array) public plugin_init() //This is the public that starts the plugin registration { //This is The Bracket To Start A Plugin Public register_plugin("Loaner","1.0","Dizzy") //This is where you put the Name,Verision,and Author //----------------------------------------- //CVARS //----------------------------------------- register_cvar("sv_loan","1") //This is a cvar. This is a command that you can shut off and on a plugin or used for other things register_cvar("sv_loanmoney","1") //Another Cvar register_cvar("sv_loanhealth","1") // Another Cvar //----------------------------------------- //CLIENT COMMANDS //----------------------------------------- register_clcmd("say /loanmoney","money") //This is A Client Command It is said by clients (players) in game register_clcmd("say /loanhealth","health") //Another Client Command //----------------------------------------- //CONSOLE COMMANDS //----------------------------------------- register_concmd("loanmoney","money") // This is A Console Command It Is Used When Typed In The Console register_concmd("loanhealth","health") // Another Console Command //----------------------------------------- //EVENTS //----------------------------------------- register_event("ResetHUD","roundchange","b") // This Is An Event This Takes Place When Registered. (Every Round Reset) //----------------------------------------- } //The Closing Bracket public client_connect(id) { //This is A Public Connect (When Client (player) connects) hasloaned[32] = false (Using Our (new bool:) we use the phrase hasloaned[32] = false) That states that on connect the client has not loaned } public client_disconnect(id) { //Here it states the same thing but only on the disconnect hasloaned[32] = false } public money(id) //This is The Start Of Our Money Public (Above We put register_clcmd("say /loanmoney","money") The Money States To Go To The public money { if (get_cvar_num("sv_loan")==0) // This checks if the cvar is on return PLUGIN_HANDLED //As you see above it isn't soo it return PLUGIN_HANDLED (which ends the plugin) if (get_cvar_num("sv_loanmoney")==0) // This checks the other cvar return PLUGIN_HANDLED // And returns it :) cs_set_user_money(id, cs_get_user_money(id) + 500) //If all passes it continues the money part and sets there money gets it and adds 500 // the cs_set_user_money above means it needs CS (Counter-Strike) That's why we need the cstrike module :) public health(id) //This is the start of our health one (we nickname the health (id)) { if (get_cvar_num("sv_loan")==0) return PLUGIN_HANDLED if (get_cvar_num("sv_loanhealth")==0) return PLUGIN_HANDLED set_user_health(id, get_user_health(id) + 10) hasloaned[id] = true return PLUGIN_CONTINUE } public roundchange(id) // This is the event roundchange and it states { if hasloaned[id] = true //if they have loaned (if hasloaned[id] = true) it stops the plugin Basically saying if they loaned already don't let them do it again)(And It stop/continues the plugin) return PLUGIN_CONTINUE } // end of the plugin

Hope This Helps You Guys Out! Please Comment If You Have A Concern.
Thanks!
__________________
My Plugins

Purchase Mod - Stable
Type Sounds - Stable
Monster Spawner - Stable
Nade Giver - Maintenance
Dizzy is offline
Send a message via AIM to Dizzy
twistedeuphoria
Veteran Member
Join Date: Jul 2004
Old 12-24-2004 , 13:38  
#2

In client connect and disconnect hasloaned[32] = false should be hasloand[id] = false. Also you have to create an array of 33 becasuse 0 = server. Looks like you forgot some paranthesis if hasloaned[id] = true .
__________________
twistedeuphoria is offline
svendude
Member
Join Date: Aug 2004
Old 12-24-2004 , 18:53  
#3

you also forgot to make new comments on some comment lines. In other words you forgot to add // on some of them.

uuhh, if you can, can you try to compile it just to test to make sure you got it right (don't have to test)
__________________
Sorry for being gone so long
svendude is offline
Send a message via Yahoo to svendude
Old 12-25-2004, 00:53
XxAvalanchexX
This message has been deleted by XxAvalanchexX. Reason: silly post made two years ago... what was I thinking
twistedeuphoria
Veteran Member
Join Date: Jul 2004
Old 12-25-2004 , 04:15  
#4

MaYbE hE wAs TrYiNg To MaKe An ExTeNdEd TiTlE aNd CoUlDn'T sToP.
__________________
twistedeuphoria is offline
ThomasNguyen
Senior Member
Join Date: May 2006
Old 09-21-2006 , 20:59   Re: A Simple Tutorial
#5

Thanks Dizzy! you really helped me. i can make simple plugins now. + karma for you
__________________
ThomasNguyen is offline
k007
BANNED
Join Date: Mar 2006
Location: bacon?
Old 09-21-2006 , 22:04   Re: A Simple Tutorial
#6

#include <cstrike> it's a module and it has it own inlcluded if u look under scripting/includes/ you will find all include files and native inside them and for the event you could find a list of even by using a server consol and typing meta game
k007 is offline
Send a message via MSN to k007
Zenith77
Veteran Member
Join Date: Aug 2005
Old 09-21-2006 , 22:17   Re: A Simple Tutorial
#7

Indention ftw.

Code:
if hasloaned[id] = true //if they have loaned (if hasloaned[id] = true) it stops the plugin Basically saying if they loaned already don't let them do it again)(And It stop/continues the plugin)

It's obvious what's wrong here.
Also, please only post code that actually works, and can be used a model for beginners so they can become better.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred

Last edited by Zenith77; 09-21-2006 at 22:20.
Zenith77 is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 09-22-2006 , 04:51   Re: A Simple Tutorial
#8

In my opinion this shouldn't be here.

1. You didn't even care to compile it to check if it compiles without issues.
2. Poorly coded. For example this
Quote:
register_event("ResetHUD","roundchange","b")
is not realted to a round. You should read this for details: http://forums.alliedmods.net/showthread.php?t=42159
3. Lack of indentation makes your code more hard to read.
4. Misleading comments. For example
Quote:
#include <fun> //This is A Module. The Fun Module It is included in this plugin
This is not a module, but a pawn directive that includes the fun.inc file that contain a set of the Fun module natives.

EDIT: Just realised that it was an old thread but anyway my comments is still valid.

Last edited by VEN; 09-22-2006 at 04:56.
VEN is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 09-22-2006 , 12:22   Re: A Simple Tutorial
#9

Oh wow, didn't realize that it was a two year old thread. I assumed it was fairly new because I've never seen the tutorial before and people where responding .
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Closed Thread



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 23:51.


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