Page 1 of 1

A Simple Tutorial

Posted: Sat Aug 15, 2026 2:10 am
by Archive-Poster
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: Select all

//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! :D

Re: A Simple Tutorial

Posted: Sat Aug 15, 2026 2:12 am
by Archive-Poster
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 ;)

Re: A Simple Tutorial

Posted: Sat Aug 15, 2026 2:14 am
by Archive-Poster
#include <cstrike> it's a module and it has it own included 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 console and typing meta game

Re: A Simple Tutorial

Posted: Sat Aug 15, 2026 2:18 am
by Archive-Poster
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

Code: Select all

register_event("ResetHUD","roundchange","b")
is not related to a round.
3. Lack of indentation makes your code more hard to read.
4. Misleading comments. For example

Code: Select all

#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 are still valid.