Raised This Month: $ Target: $400
 0% 

[HELP] With the user origin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fiendshard
Senior Member
Join Date: Dec 2009
Location: In Water
Old 10-08-2010 , 19:17   [HELP] With the user origin
Reply With Quote #1

Hello people, i was wondering if someone may help with this piece of code. It doesn't compile and I am not sure why. Here it is:

Code:
#include <amxmodx>

new light

public plugin_init() 
{	
	register_plugin("Storm","1.0","fiend")
	register_clcmd("say /storm", "makestorm"); 
}

public plugin_precache() 
{ 
	light = precache_model("sprites/lgtning.spr") 
}

public makestorm(id)
{
	{
	new xy[2]
	xy[0] = random_num(0,2200)
	xy[1] = random_num(0,2200)
	set_task(0.5,"lightning",1324,xy,10,"a", 60)
	set_task(1.0,"lightning1",1325,xy,10,"a", 60)
	set_task(1.5,"lightning2",1326,xy,10,"a", 60)
	set_task(2.0,"lightning3",1327,xy,10,"a", 60)
	set_task(2.5,"lightning4",1328,xy,10,"a", 60)
	set_task(3.0,"lightning5",1329,xy,10,"a", 60)
	}
	return PLUGIN_HANDLED
}

public lightning(xy[])
{
	xy[0] = random_num(-2000,2200)
	xy[1] = random_num(-2000,2200)
	message_begin(MSG_BROADCAST,SVC_TEMPENTITY) 
	write_byte(0) 
	write_coord(xy[0]) 
	write_coord(xy[1]) 
	write_coord(4000) 
	write_coord(xy[0]) 
	write_coord(xy[1]) 
	write_coord(-2000) 
	write_short(light) 
	write_byte(1) // framestart 
	write_byte(5) // framerate 
	write_byte(2) // life 
	write_byte(200) // width 
	write_byte(10) // noise 
	write_byte(0) // r, g, b 
	write_byte(255) // r, g, b 
	write_byte(0) // r, g, b 
	write_byte(200) // brightness 
	write_byte(200) //  
	message_end() 
}

public lightning1(xy[])
{
	xy[0] = random_num(-2000,2200)
	xy[1] = random_num(-2000,2200)
	message_begin(MSG_BROADCAST,SVC_TEMPENTITY) 
	write_byte(0) 
	write_coord(xy[0]) 
	write_coord(xy[1]) 
	write_coord(4000) 
	write_coord(xy[0]) 
	write_coord(xy[1]) 
	write_coord(-2000) 
	write_short(light) 
	write_byte(1) // framestart 
	write_byte(5) // framerate 
	write_byte(2) // life 
	write_byte(200) // width 
	write_byte(10) // noise 
	write_byte(0) // r, g, b 
	write_byte(255) // r, g, b 
	write_byte(0) // r, g, b 
	write_byte(200) // brightness 
	write_byte(200) //  
	message_end() 
}

public lightning2(xy[])
{
	xy[0] = random_num(-2000,2200)
	xy[1] = random_num(-2000,2200)
	message_begin(MSG_BROADCAST,SVC_TEMPENTITY) 
	write_byte(0) 
	write_coord(xy[0]) 
	write_coord(xy[1]) 
	write_coord(4000) 
	write_coord(xy[0]) 
	write_coord(xy[1]) 
	write_coord(-2000) 
	write_short(light) 
	write_byte(1) // framestart 
	write_byte(5) // framerate 
	write_byte(2) // life 
	write_byte(200) // width 
	write_byte(10) // noise 
	write_byte(0) // r, g, b 
	write_byte(255) // r, g, b 
	write_byte(0) // r, g, b 
	write_byte(200) // brightness 
	write_byte(200) //  
	message_end() 
}

public lightning3(xy[])
{
	xy[0] = random_num(-2000,2200)
	xy[1] = random_num(-2000,2200)
	message_begin(MSG_BROADCAST,SVC_TEMPENTITY) 
	write_byte(0) 
	write_coord(xy[0]) 
	write_coord(xy[1]) 
	write_coord(4000) 
	write_coord(xy[0]) 
	write_coord(xy[1]) 
	write_coord(-2000) 
	write_short(light) 
	write_byte(1) // framestart 
	write_byte(5) // framerate 
	write_byte(2) // life 
	write_byte(200) // width 
	write_byte(10) // noise 
	write_byte(0) // r, g, b 
	write_byte(255) // r, g, b 
	write_byte(0) // r, g, b 
	write_byte(200) // brightness 
	write_byte(200) //  
	message_end() 
}

public lightning4(xy[])
{
	xy[0] = random_num(-2000,2200)
	xy[1] = random_num(-2000,2200)
	message_begin(MSG_BROADCAST,SVC_TEMPENTITY) 
	write_byte(0) 
	write_coord(xy[0]) 
	write_coord(xy[1]) 
	write_coord(4000) 
	write_coord(xy[0]) 
	write_coord(xy[1]) 
	write_coord(-2000) 
	write_short(light) 
	write_byte(1) // framestart 
	write_byte(5) // framerate 
	write_byte(2) // life 
	write_byte(200) // width 
	write_byte(10) // noise 
	write_byte(0) // r, g, b 
	write_byte(255) // r, g, b 
	write_byte(0) // r, g, b 
	write_byte(200) // brightness 
	write_byte(200) //  
	message_end() 
}

public lightning5(xy[], id)
{
	xy[0] = random_num(-2000,2200)
	xy[1] = random_num(-2000,2200)
	message_begin(MSG_BROADCAST,SVC_TEMPENTITY) 
	write_byte(0) 
	write_coord(xy[0]) 
	write_coord(xy[1]) 
	write_coord(4000) 
	write_coord(xy[0]) 
	write_coord(xy[1]) 
	write_coord(-2000) 
	write_short(light) 
	write_byte(1) // framestart 
	write_byte(5) // framerate 
	write_byte(2) // life 
	write_byte(200) // width 
	write_byte(10) // noise 
	write_byte(0) // r, g, b 
	write_byte(255) // r, g, b 
	write_byte(0) // r, g, b 
	write_byte(200) // brightness 
	write_byte(200) //  
	message_end() 
	
	if(get_user_origin(id) ==  (xy[1]))
	user_kill(id)
	
	if(get_user_origin(id) ==  (xy[0]))
	user_kill(id)

}
Problem is with last two chunks of code.

Also would like to ask if it is possible to get user origin when origin is randomized?

Other than this, how can i make action when sprite used in this code collide with player? That would solve the problem.

Thank you
__________________

Last edited by fiendshard; 10-08-2010 at 19:19.
fiendshard is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 10-08-2010 , 22:51   Re: [HELP] With the user origin
Reply With Quote #2

Post the compiling errors because people don't have time to copy and compile your code.

Also, why are you using 5 functions to do the exact thing ?

Oh and I think I saw your problem... get_user_origin(), you need to parse an array to that, you can't compare it directly, see funcwiki for detailed info.
__________________

Last edited by Hunter-Digital; 10-08-2010 at 22:55.
Hunter-Digital is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-08-2010 , 23:10   Re: [HELP] With the user origin
Reply With Quote #3

This xy variable does NOTHING.

PHP Code:
public makestorm(id)
{
    {
    new 
xy[2]
    
xy[0] = random_num(0,2200)
    
xy[1] = random_num(0,2200
Quote:
Originally Posted by Hunter-Digital View Post
Oh and I think I saw your problem... get_user_origin(), you need to parse an array to that, you can't compare it directly, see funcwiki for detailed info.
Yep, that's the one.
__________________
fysiks is offline
fiendshard
Senior Member
Join Date: Dec 2009
Location: In Water
Old 10-09-2010 , 04:46   Re: [HELP] With the user origin
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
This xy variable does NOTHING.

PHP Code:
public makestorm(id)
{
    {
    new 
xy[2]
    
xy[0] = random_num(0,2200)
    
xy[1] = random_num(0,2200


Yep, that's the one.
Thank you for replies guys. Here are compiling errors:

Code:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

Error: Number of arguments does not match definition on line 190
Error: Number of arguments does not match definition on line 193

2 Errors.
I checked funcwiki and made suggested corrections but no luck so far
__________________
fiendshard is offline
fiendshard
Senior Member
Join Date: Dec 2009
Location: In Water
Old 10-09-2010 , 13:16   Re: [HELP] With the user origin
Reply With Quote #5

All right, I finally realized how to make it compile without errors, but in game i get this:

L 10/09/2010 - 18:581: [AMXX] [0] storm.sma::lightning5 (line 24)
L 10/09/2010 - 18:581: Invalid player id 0
L 10/09/2010 - 18:581: [AMXX] Displaying debug trace (plugin "storm.amxx")
L 10/09/2010 - 18:581: [AMXX] Run time error 10: native error (native "get_user_origin")

Here is changed code:

Code:
#include <amxmodx>

new light

public plugin_init() 
{	
	register_plugin("Storm","1.0","fiend")
	register_clcmd("say /storm", "makestorm"); 
}

public plugin_precache() 
{ 
	light = precache_model("sprites/lgtning.spr") 
}

public makestorm(id)
{
	{
	set_task(3.0,"lightning5",id,"",0,"a",60)
	}
	return PLUGIN_HANDLED
}

public lightning5(xy[], id)
{
	xy[0] = random_num(-2000,2200)
	xy[1] = random_num(-2000,2200)
	message_begin(MSG_BROADCAST,SVC_TEMPENTITY) 
	write_byte(0) 
	write_coord(xy[0]) 
	write_coord(xy[1]) 
	write_coord(4000) 
	write_coord(xy[0]) 
	write_coord(xy[1]) 
	write_coord(-2000) 
	write_short(light) 
	write_byte(1) // framestart 
	write_byte(5) // framerate 
	write_byte(2) // life 
	write_byte(200) // width 
	write_byte(10) // noise 
	write_byte(0) // r, g, b 
	write_byte(255) // r, g, b 
	write_byte(0) // r, g, b 
	write_byte(200) // brightness 
	write_byte(200) //  
	message_end() 
	

	new origin[3];
	get_user_origin(id, origin)
	{
		if((origin[0] = xy[0]) && (origin[1] = xy[1]))
		user_kill(id)
	}	
	

}
What i am doing wrong? it is supposed to kill player when he happens to be at xy[0] and xy[1] location on map at the moment of lightning task (lightning strike)
__________________
fiendshard is offline
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 10-09-2010 , 13:40   Re: [HELP] With the user origin
Reply With Quote #6

Change this:
Code:
public lightning5(xy[], id)
to
Code:
public lightning5(id)
since xy[] is not passed by the task !!
__________________

My Plugins For ZP

Inactive due to College and Studies
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
Reply


Thread Tools
Display Modes

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 10:21.


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