View Single Post
  #4  
Old 08-20-2013, 01:37 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by i8bit View Post
And what should I put in the params to target the player right in front of me?
You don't do anything with the params, you need to call that on the appropriate player. The typical approach is to loop through the players near you and check if any of them are in the attack radius. If they are, attack them, either by triggering one of their weapons clientside or handling the attack serverside (preferred).

(I think I recall Stefan adding a better way to find players in a certain radius/area? The forums search isn't working as usual so not sure)

Quote:
So essentially, I don't even need to trigger serverside to trigger a clientside function in another player?
You can do it this way but it's quite unreliable and in my opinion the approach of triggering serverside and allowing the server to handle attacks (which is what you were doing in your first post) is much more reasonable. Point triggers are very unreliable and you can end up with cases where attacks don't hit for a number of hard-to-find reasons.

The approach you were using before avoids all of those and gives you much more flexibility (for example, instead of point attacks which are very limited you are free to use your own attack radii, or even special attack patterns for different weapons). You also get the benefit of handling things serverside which is inherently more reliable.

edit: I read callimuc's post wrong, he was only talking about for NPCs. You can use point triggers for that but they are still very unreliable. A preferred solution would be to handle NPCs the same way as players (loop through them and use the same attack/hitbox logic; use something like npc.trigger("hurt", player, damage); to call onHurt in an NPC).
__________________
Reply With Quote