AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Newbie Scripter - First Plugin - Need Help don't Laugh :) (https://forums.alliedmods.net/showthread.php?t=12491)

eXist 04-16-2005 20:30

Newbie Scripter - First Plugin - Need Help don't Laugh :)
 
I'm a first timer, and after studying up on the small language, I decided to write my first plugin in order to become better and gain more experience.
My first Plugin is desiged to stack a User upon the admin that sent the command. I haven't been able to test my plugin yet because of a compling error.

(Line 38 ) Compiling Error 017 : Undefined Symbol "set_user_origin"

I've read up on the error, and I have been unable to understand the problem. I've looked at other "Stack" Plugins and they haven't help much either.

If someone could help me with this problem it would be very much appriciated.

I apologize if my code is completely falty in the long run, I'm trying.

Code:
#include <amxmodx> #define PLUGIN_NAME "Stack X" #define PLUGIN_VERSION "1.0" #define PLUGIN_AUTHOR "eXist`" public plugin_init()     {         register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)         register_concmd("amx_stackx", "stack_x", ADMIN_KICK, "user Define a Player to be stacked upon yourself.")     }     public stack_x(id)     {         if (get_user_flags(id) != ADMIN_KICK)             {                 console_print(id, "[AMXX] You have no access to that command!")                 return PLUGIN_HANDLED             }         if (read_argc() == 0)             {                 console_print(id, "[AMXX] Please Specify a User")                 return PLUGIN_HANDLED             }         new user[32], uid         read_argv(1,user,32)         uid = find_player("bh",user)         if (uid == 0)             {                   console_print(id,"[AMXX] Invalid User Id")                 return PLUGIN_HANDLED             }         new origin[3]         if (uid == 1)             {                 get_user_origin(id, origin, 0)                 origin[2] = origin[2] + 50                 set_user_origin(uid, origin)                 return PLUGIN_HANDLED             }     }

v3x 04-16-2005 20:36

No need to laugh. :)

Code:
#include <fun> // Fun module is required for set_user_origin()

Also, before the last } put: return PLUGIN_HANDLED

--

Code:
#include <amxmodx> #include <amxmisc> #include <fun> #define PLUGIN_NAME "Stack X" #define PLUGIN_VERSION "1.0" #define PLUGIN_AUTHOR "eXist`" public plugin_init() {     register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)     register_concmd("amx_stackx", "stack_x", ADMIN_KICK, "user Define a Player to be stacked upon yourself.") } public stack_x(id,level,cid) {     if (!cmd_access(id,level,cid,1)) {         //console_print(id, "[AMXX] You have no access to that command!")         // Not needed because it will already be printed!         return PLUGIN_HANDLED     }     new user[33]     read_argv(1,user,32)     new player = cmd_target(id,user,1+2)     if(!is_user_connected(player) || !is_user_alive(player)) {         return PLUGIN_HANDLED     }     new origin[3]     get_user_origin(id, origin, 0)     origin[2] = origin[2] + 50     set_user_origin(player, origin)     return PLUGIN_HANDLED }

(Sorry about editing like post like 10 times!) :P

eXist 04-16-2005 20:55

Thanks
 
*Bows to the Scripting God*

Permision to laugh granted

Thanks very much for the extremly fast reply, amazing :)
6 minutes later thats some kind of god you must be. I like you already Vex: Your a very helpful guy, thanks.

I had a feeling it might be a problem with the includes.

Yea it was funny i saw the post constanly changing :)

Can you help me understand these lines

Code:
    new player = cmd_target(id,user,1+2)     if(!is_user_connected(player) || !is_user_alive(player)) {         return PLUGIN_HANDLED

v3x 04-16-2005 21:01

Scripting God? Ha! :lol:

Code:
new player = cmd_target(id,user,1+2)
cmd_target() locates a player's id. The 1+2 part means "obey immunity + allow immune admin to perform on self".
Quote:

Flags:
1 - obey immunity
2 - allow yourself
4 - must be alive
8 - can't be bot
Code:
if(!is_user_connected(player) || !is_user_alive(player))
Well, let's make this simple.. If the user isn't connected OR the user isn't alive, stop the rest of the function from being executed. :)

eXist 04-16-2005 21:06

Yea sorry i got antsy, asking before i tried to figure it out.
I got it after like 2 seconds after i posted, sorry for wasting you time.
It definatly compiles now, thanks.

One more question.

I had read an ealier post of yours that says to ignore the:
Compile warming 217: loose intention.
I was wondering if there is a way to fix this (beacuse my plugin has 3) or if it may cause problems if i dont fix it.

v3x 04-16-2005 21:09

It means you didn't make the proper indentations. Everything must be consistent. Hell, if you don't feel like indenting your code, stick it in the online-indenter (I recommend unchecking the box)!

I prefer using tabs, some people prefer using spaces. It's really just personal preference.

eXist 04-16-2005 21:11

Thanks ill try it out.

Also, can i keep this piece of code? or is it a worthless dumb :)

Code:
if (read_argc() == 0)             {                 console_print(id, "[AMXX] Please Specify a User")                 return PLUGIN_HANDLED

v3x 04-16-2005 21:14

Worthless indeed. :)

I replaced that with that other if() statement (checking if the user is connected/alive).

eXist 04-16-2005 21:20

Thanks for all your help. Complied Perfect, no errors intened.

Sorry to bother for one last time, but i need some for help figuring out these lines, i looked them up but im still troubled, also embarassed for being so nub :oops:

Code:
public stack_x(id,level,cid) {     if (!cmd_access(id,level,cid,1))

I just dont understand the (id,level,cid) and the (id,level,cid,1).
Sorry bout that

v3x 04-16-2005 21:27

Not sure how to explain it. :?

Code:
if(!cmd_access(id,level,cid,1))
It grabs the access level from the command, in this case it's "ADMIN_KICK". 1 means only 1 argument when called. If it returns false (0), the stuff inside the curly brackets will execute.
Quote:

The last parameter (num) is the number of arguments.
Note that the first parameter is the command name so if you expect one param set it to 2.
Sorry if I confused you..


All times are GMT -4. The time now is 09:55.

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