Raised This Month: $51 Target: $400
 12% 

i don't understanding get_user_origin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Crazywelder1
Member
Join Date: Mar 2004
Location: CA
Old 02-08-2005 , 19:56   i don't understanding get_user_origin
Reply With Quote #1

okay my problem is that i want to use get_user_origin so i can have a bolt of lightning hit the person.. and at this point i get one error and one warning
one: error 029: invaild expression,assumed zero (on the line get_user_origin)
second: warning 225: unreachable code (same thing)

here is some of the code the section i am have problems with..

Code:
new origin[33][3]     get_user_origin(id,origin[id])      message_begin(MSG_ALL,SVC_TEMPENTITY)     write_byte(7) // number of tempevent     write_coord(origin[id][0]) // x coord     write_coord(origin[id][1]) // y coord     write_coord(origin[id][2]) // z coord     write_coord(origin[id][0]) // x2 coord     write_coord(origin[id][1]) // y2 coord     write_coord(origin[id][2]) + 10 // z2 coord     write_byte(2) // life     write_byte(5) // width     write_byte(5) // amplitude     write_short(light) // sprite index     message_end()
ty for your time!!! extremely aprreciated
Crazywelder1 is offline
Send a message via MSN to Crazywelder1
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 02-08-2005 , 20:16  
Reply With Quote #2

This is your exact same code that you posted, only changed slightly (includes, declaration of light variable, and inside a public function), and it works without any warnings:

Code:
#include <amxmodx> #include <fun> new light; public function(id) {     new origin[33][3]     get_user_origin(id,origin[id])        message_begin(MSG_ALL,SVC_TEMPENTITY)     write_byte(7) // number of tempevent     write_coord(origin[id][0]) // x coord     write_coord(origin[id][1]) // y coord     write_coord(origin[id][2]) // z coord     write_coord(origin[id][0]) // x2 coord     write_coord(origin[id][1]) // y2 coord     write_coord(origin[id][2]) + 10 // z2 coord     write_byte(2) // life     write_byte(5) // width     write_byte(5) // amplitude     write_short(light) // sprite index     message_end() }

Although maybe my compiler is broken. Change the z2 coord line so that + 10 is within the parentheses.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Crazywelder1
Member
Join Date: Mar 2004
Location: CA
Old 02-08-2005 , 20:22  
Reply With Quote #3

ummm i know all of that.. did u read wat i posted??? i am showing u my problem and where it is.. wat i am asking is if u could help me figure out how to fix it

here i make it easier ill give u the whole code its been modify from someone elses code that he needed fixed and the reason i used it is because i want to learn how to make the lightning. for a plugin i am making .
Code:
#include <amxmodx> #include <amxmisc> #include <fun> #include <engine> #include <amxconst> new light public plugin_init() {     register_plugin("Unknown", "0.5", "Garrett")     register_clcmd("say givemegod", "saygod", ADMIN_KICK, "-gives player godmode") } public plugin_precache() {     light = precache_model("sprites/lgtning.spr")     return PLUGIN_HANDLED } public saygod(id) {     if(get_user_flags(id)&&ADMIN_KICK)     set_user_godmode(id)     return PLUGIN_HANDLED     else (!get_user_flags(id)&&ADMIN_KICK)         client_print(id, print_chat, "[AMXX] HAHAHA nice try!")         new origin[33][3]     get_user_origin(id,origin[id])      message_begin(MSG_ALL,SVC_TEMPENTITY)     write_byte(7) // number of tempevent     write_coord(origin[id][0]) // x coord     write_coord(origin[id][1]) // y coord     write_coord(origin[id][2]) // z coord     write_coord(origin[id][0]) // x2 coord     write_coord(origin[id][1]) // y2 coord     write_coord(origin[id][2]) + 10 // z2 coord     write_byte(2) // life     write_byte(5) // width     write_byte(5) // amplitude     write_short(light) // sprite index     message_end()     return PLUGIN_HANDLED }
__________________
AKA = oM`|Garrett
oM CLAN
Soon to have a server in Soon
Crazywelder1 is offline
Send a message via MSN to Crazywelder1
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 02-08-2005 , 21:09  
Reply With Quote #4

For starters, Avalanche did provide adequate help (but missed the write_coord(origin[id][2]) + 10 bit ), you just didn't specify exactly what you wanted.. it seems more clear from your second post, so I will guess at what it is you want and try to provide a brief explanation..

Well, you dont need origin[33][3] if you are using the origins locally only, so use origin[3] instead, since you dont need to store the origins of every player when you are only using the origins of one player..

Basically, get_user_origin() function accepts 2 parameters: the id of the user to get the origin of (which I am sure you understood that) and secondly is an array of 3 variables which specify the X, Y, Z coordinates of the user in 3D Space... You simply make an array of 3 like:

new MyOriginArray[3]

Then pass it to the function like:

get_user_origin( id, MyOriginArray )

Then, after the call to that function, the array will hold the users coordinates:

MyOriginArray[0] will equal the X Coordinate
MyOriginArray[1] will equal the Y Coordinate
MyOriginArray[2] will equal the Z Coordinate


Also, try not to return PLUGIN_HANDLED from AMXX Forwards like plugin_init() or plugin_precache() etc.. , return PLUGIN_CONTINUE instead..

You dont need to include <amxconst> since it is included already by <amxmodx>

This block is completely wrong:
Code:
    if(get_user_flags(id)&&ADMIN_KICK)     set_user_godmode(id)     return PLUGIN_HANDLED     else (!get_user_flags(id)&&ADMIN_KICK)         client_print(id, print_chat, "[AMXX] HAHAHA nice try!")

if(get_user_flags(id)&&ADMIN_KICK)

should be:

if(get_user_flags(id)&ADMIN_KICK)

Notice the single ampersand (&) which specifies Bit-Wise Comparison...

Also there should be Curly-Brackets around the first IF clause (because you have more than one statement), the "else" should be "else if" since you are specifying an additional comparison (otherwise leave out everything after "else" on the same line)

Plus your logic is wrong, you have: If the user has Access give god mode then exit function, else if user doesnt have access then print a message and do the lightning effect (which seems wrong, maybe that was your intentions, idk)...

Lastly, you had:

write_coord(origin[2]) + 10 // z2 coord

which should be:

write_coord(origin[2] + 10) // z2 coord

Notice the + 10 is inside the brackets, so that the sum is calculated first, then the resulting value is passed to the write_coord() function..

I hope that helps a bit, also here is a revised version (not tested)..

Code:
#include <amxmodx> #include <amxmisc> #include <fun> #include <engine> new light public plugin_init() {     register_plugin("Unknown", "0.5", "Garrett")     register_clcmd("say givemegod", "saygod", ADMIN_KICK, "-gives player godmode") } public plugin_precache() {     light = precache_model("sprites/lgtning.spr")     return PLUGIN_CONTINUE } public saygod(id) {     if( !(get_user_flags(id)&ADMIN_KICK) )     {         client_print(id, print_chat, "[AMXX] HAHAHA nice try!")         return PLUGIN_HANDLED     }     // Set God Mode on User     set_user_godmode(id)     // Generate Lightning at user origin     new origin[3]     get_user_origin(id,origin)      message_begin(MSG_ALL,SVC_TEMPENTITY)     write_byte(7) // number of tempevent     write_coord(origin[0]) // x coord     write_coord(origin[1]) // y coord     write_coord(origin[2]) // z coord     write_coord(origin[0]) // x2 coord     write_coord(origin[1]) // y2 coord     write_coord(origin[2] + 10) // z2 coord     write_byte(2) // life     write_byte(5) // width     write_byte(5) // amplitude     write_short(light) // sprite index     message_end()     return PLUGIN_HANDLED }
xeroblood is offline
Send a message via MSN to xeroblood
Da Bishop
Senior Member
Join Date: Aug 2004
Location: Chester County PA
Old 02-08-2005 , 21:33  
Reply With Quote #5

blood you should be writing scripts not semi tutorials
__________________
Anything that is done can only be done better by urself - since life is a opinion make it the way urs feel its best

~live by it
Da Bishop is offline
Send a message via MSN to Da Bishop
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 02-08-2005 , 21:49  
Reply With Quote #6

heehee, i guess that was a bit much..

I have released a few plugins actually (More for AMX, mainly since it was around longer), but most of the ideas I think of have been done already so it is hard to find something original to release.. Also, my time constraints make it difficult to code much, so my progress on plugins is slow

(Yes, my creative aspirations are currently limited)
xeroblood is offline
Send a message via MSN to xeroblood
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 02-08-2005 , 23:11  
Reply With Quote #7

Quote:
Originally Posted by xeroblood
For starters, Avalanche did provide adequate help (but missed the write_coord(origin[id][2]) + 10 bit )
No, I told him that was wrong. The code bit was exactly his code, the point of posting that was that it works and the errors are coming from something else. I didn't change that, but I did tell him about it.

Quote:
Originally Posted by xeroblood
Basically, get_user_origin() function accepts 2 parameters:
It takes 3 parameters, the third is optional.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Crazywelder1
Member
Join Date: Mar 2004
Location: CA
Old 02-09-2005 , 10:29  
Reply With Quote #8

thank u xeroblood mainly(and some to avlanche) and well i have idea for u why dont u make a plugin where everyone has no clip so it becomes a no clip war but what u do is make boundaries of where they can't go... (if that is possible(i would think it is) and maybe have some other things i can't think of

thank u for the time u spent explaining it to me..
__________________
AKA = oM`|Garrett
oM CLAN
Soon to have a server in Soon
Crazywelder1 is offline
Send a message via MSN to Crazywelder1
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 02-09-2005 , 11:36  
Reply With Quote #9

Glad I could help..

@Avalanche:

I'm just buggin ya

But I did say "Basically" meaning that is the basic (simple) way of it, and I didn't want to explain stuff that wasn't needed in his plugin..
xeroblood is offline
Send a message via MSN to xeroblood
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 02-09-2005 , 15:10  
Reply With Quote #10

Quote:
Originally Posted by xeroblood
heehee, i guess that was a bit much..

I have released a few plugins actually (More for AMX, mainly since it was around longer), but most of the ideas I think of have been done already so it is hard to find something original to release.. Also, my time constraints make it difficult to code much, so my progress on plugins is slow

(Yes, my creative aspirations are currently limited)
Yes, xero...you should read my email about a plugin I suggested .
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x 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 17:05.


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