![]() |
Custom Projectile
PHP Code:
Well, it works fine unill now, the only part that is missing, is the damage part. Well, I am stuck, how can I make it damage on Hit, without using shoot()? |
You'll have to detect in a timeout if the projectile is on a player/npc, and thus... BOOM.
|
I'd probably do something like this in the timeout loop:
PHP Code:
|
Might be easier or more efficient to use findnearestplayer()
|
Quote:
Thanks. |
PHP Code:
|
Quote:
o_O |
Quote:
|
Well, I don't have any NPCs :D
|
you will if you're making an era type server, trust me.
|
I'd also use a gani for the bullet, rather than it being a static image.
|
Well.
Thanks again, I got another question tho: I am trying to make the projectile destroy after 3 seconds, so I'm using: scheduleevent(3,"StarDestroy",""); function onStarDestroy() { triggeraction(this.x + 6/16, this.y + 6/16, "StarDestroy", nil); } function onActionStar() { this.destroy(); } And it doesnt work x_X, am I triggering it wrong, or what? :o |
Why are you triggering an action to destroy it? Just destroy it in the function.
|
Uhm..
Well, because when I use this.destroy(); clientside, it doesn't really destroy it o_O |
Quote:
PHP Code:
|
Good idea, but I'm using a function onCreated Clientside already and I need that function onCreated Clientside, because I start a timer clientside with that function, which is needed oO
Also "destroy();" would destroy the whole script I heard xD |
Quote:
Quote:
|
Really?
Awesome, thank you. I'll try that :D Works perfect. Thanks. |
Ok another thing.
I decided to move the projectile serverside, because I was told that I had to do it like that, so it looks somewhat like this: PHP Code:
The projectile gets spawned in front of my player, yes, but it doesn't move anymore. While debugging I figured out that "this.spread" and "this.dird" are both 0 now and won't get set to what I want them to get set oO x_X Anyone? |
That's because "onCreated" serversided in a local NPC isn't an event triggered related to a player, so "player" equals NULL.
You'll need to pass the player object through your putnpc function, similar to this: PHP Code:
|
I don't get it :(
|
Post the part of your code that you use to spawn projectiles please. :whatever:
|
function onActionServerSide() {
putnpc2(params[0],params[1],"join bullet;"); } |
Quote:
PHP Code:
|
Change that, too...
PHP Code:
PHP Code:
|
Yes I know.. it works fine.
But I don't understand it lol x_X Why "this.ower"? What's this? x_X: "temp.proj.owner = player;" Why "NULL"?! Wtf?! temp.proj.join("bullet"); |
Can't I just set "this.dird" and "this.spread" in a "function onCreated" Clientside and then send it to the server?
If I can do that, how do I send it to the server using triggeraction? Omg I am so confused lol |
Quote:
|
Quote:
Quote:
Quote:
Quote:
temp.npc = putnpc(x, y, ""); - This spawns an NPC on the coordinates x and y. By doing it like this you can change the values of the spawned NPC by accessing "temp.npc". npc.owner = player - This sets the this.owner in the projectile to the player object, so you can access data from the player who spawned the projectile. npc.join("bullet"); - This joins the newly spawned NPC to your projectile class. Just try the code I gave you man, it'll work. |
Thank you.
I'll read this 50 times now untill I understand it :D Also what you gave me doesn't work. |
Quote:
|
| All times are GMT +2. The time now is 08:20 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.