Raised This Month: $ Target: $400
 0% 

My script


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kasc
Junior Member
Join Date: Mar 2005
Location: The Grand UK!
Old 03-29-2005 , 08:16   My script
Reply With Quote #1

Hi, i'm extremly new to Small and its bynaries and syntax (confused already ) Here's my code so far :
Code:
#include <amxmodx>
#include <amxmisc>


new PLUGIN[]="You Are Stupid"
new AUTHOR[]="Kasc"
new VERSION[]="1.00"

public plugin_init()
{
     register_plugin(PLUGIN, VERSION, AUTHOR)
     register_clcmd("amx_urstupid","myfunction",AMX_HELP,"Declares that you think a specific person is stupid!")
     
} 

public myfunction(id) {
	
	
}
As u can see its a plugin that anyone can use to declare tht u think sum1 is stupid! But i dont know what to do from here
Ive figured at tht i have to use get_user_name (tell me if im wrong)

Example:
u type in console : "amx_urstupid kasc"
and it would say in HUD : "|R3VO| Kasc has just been called stupid by |R3VO| Kasc"
Please help
Thanks
__________________
I like it when you get bad karma, especially because of its randomness!
kasc is offline
Send a message via AIM to kasc Send a message via MSN to kasc
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 03-29-2005 , 18:44  
Reply With Quote #2

Code:
#include <amxmodx> #include <amxmisc> new PLUGIN[]="You Are Stupid" new AUTHOR[]="Kasc" new VERSION[]="1.00" public plugin_init() {      register_plugin(PLUGIN, VERSION, AUTHOR)      register_clcmd("amx_urstupid","myfunction",AMX_HELP,"Declares that you think a specific person is stupid!")       } public myfunction(id) {      new arg[32];      read_argv(1,arg,31);      new player = cmd_target(id,arg);      if(!player) {           return PLUGIN_HANDLED;      }      new targetname[32], myname[32];      get_user_name(player,targetname,31);      get_user_name(id,myname,31);      client_print(0,print_chat,"* %s thinks that %s is stupid!",myname,targetname);      return PLUGIN_HANDLED; }
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Silverice146
Member
Join Date: Mar 2005
Location: In a box
Old 03-29-2005 , 23:50  
Reply With Quote #3

nice,

okay idea, my first plugin (my only plugin) was one that makes the person fire their weapon


BTW: Avalanche, does your avatar change with every post I read of yours?
__________________
Silverice146 is offline
Send a message via AIM to Silverice146
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 03-30-2005 , 00:00  
Reply With Quote #4

what is AMX_HELP??
Freecode is offline
pendragon
Senior Member
Join Date: Mar 2004
Location: In a bubble
Old 03-30-2005 , 01:43  
Reply With Quote #5

Quote:
Originally Posted by Freecode
what is AMX_HELP??
@ kasc

what Freecode is gently trying to tell you is that you need to use one of the Admin Level Constants
pendragon is offline
Send a message via ICQ to pendragon
kasc
Junior Member
Join Date: Mar 2005
Location: The Grand UK!
Old 03-30-2005 , 07:39  
Reply With Quote #6

Thanks avalnche, could you possibly tell me how every thing else works, theres no point in my claiming it my own unless i dont know how it works
__________________
I like it when you get bad karma, especially because of its randomness!
kasc is offline
Send a message via AIM to kasc Send a message via MSN to kasc
XunTric
BANNED
Join Date: Jan 2005
Location: Norway/Norge
Old 03-30-2005 , 07:42  
Reply With Quote #7

Read thru AMX Mod X doc... (Scripting Part)
XunTric is offline
kasc
Junior Member
Join Date: Mar 2005
Location: The Grand UK!
Old 03-30-2005 , 07:50  
Reply With Quote #8

Okay i ahve a problem now
I get this:
[ 26] unknown unknown unknown amx_urstupid.am bad load
Load fails: Plugin file open error (plugin "amx_urstupid.amxx"

and the code:

Code:
#include <amxmodx> #include <amxmisc> new PLUGIN[]="You Are Stupid" new AUTHOR[]="Kasc" new VERSION[]="1.00" public plugin_init() {      register_plugin(PLUGIN, VERSION, AUTHOR)      register_clcmd("amx_urstupid","myfunction",ADMIN_KICK,"Declares that you think a specific person is stupid!")         } public myfunction(id) {      new arg[32];      read_argv(1,arg,31);      new player = cmd_target(id,arg);      if(!player) {           return PLUGIN_HANDLED;      }      new targetname[32], myname[32];      get_user_name(player,targetname,31);      get_user_name(id,myname,31);      client_print(0,print_chat,"* %s thinks that %s is stupid!",myname,targetname);      return PLUGIN_HANDLED; }
__________________
I like it when you get bad karma, especially because of its randomness!
kasc is offline
Send a message via AIM to kasc Send a message via MSN to kasc
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 03-30-2005 , 23:10  
Reply With Quote #9

Plugin file open error means it couldn't find the file. Did you spell it wrong? Did you place it in the plugins directory?

Anyway, an explanation.

We created the variable arg to contain our string. We then use read_argv to grab the first argument (that's what the 1 is for), we also specify the variable to store it in and how many characters to store it for (take the size of the string and subtract 1, the last character is reserved).

Then we create a new variable, player, to hold the player index of our target. We use cmd_target to find that index. The first parameter, id, is the index of who is calling the command. The second parameter is the string that contains our text, and the last parameter is certain flags.

We use if(!player) to figure out if we there was no match. If that is the case, player is 0, so it will return false. It will also print out some text to the console automatically. We then return PLUGIN_HANDLED to stop the rest of our code.

We then create some variables to hold our names and grab 'em, one variable for the person who called the command and one variable for the target.

We then use client_print to display it to everyone!
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX 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 09:53.


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