What makes a weapon function?
#1

More of a GTA question I guess but i'm curious what elements actually come into play when you fire an M4 for example? I guess you have the weapon model and the particle effect but what creates the bullets? and makes them fire from the players position etc?
Reply
#2

Quote:
Originally Posted by Infamous
View Post
More of a GTA question I guess but i'm curious what elements actually come into play when you fire an M4 for example? I guess you have the weapon model and the particle effect but what creates the bullets? and makes them fire from the players position etc?
I suppose get player offsets, add a little number to Z to match the height of the player, whether crouched/standing

get aiming offsets, and check if a weapon has been shot before for the recoil/bullets to twirl in your crosshair so the bullets look like the top ones in the pictures, not from the bottom ones. (left to right, deagle mp5 m4, both top n bottom)


Get the most far end available with object detection so bullets won't go through objects to shoot players (except some gates)

Call some function to check if there's a player is aligned with the aiming offsets, along with the recoil

If player = aligned with the aiming offsets then play animation of the getting shot, depending on what position the shooter is, add a blood particle, and remove health

(just a lil info)
Reply
#3

Thanks for the detailed reply, it would be good if we had access to the internal functions used so we could create our own systems etc.
Reply
#4

It would, all I want to be added is a function to make weapons invisible, so I can for example put the colt in the hands of a deagle without resizing and stuff, or add a load of objects to cover up the deagle to find out that people also use mods for weapons..

And yeah, you can always try making your own weapon function, I tried and succeeded at making a smith&wesson of a deagle using some variables, pvars, weapon detection and a little 3dtextlabel to show which weapon is being held
Reply
#5

Quote:
Originally Posted by JaydenJason
View Post
It would, all I want to be added is a function to make weapons invisible, so I can for example put the colt in the hands of a deagle without resizing and stuff
AFAIK, not possible in GTA. Therefore, not possible in SA-MP.
Reply
#6

From what I learn and has you said, you have the weapon model and particle effects, but you also have another thing and this thing is what makes the shot. I'm not sure if GTA is based on this but as far has I know when you want to "shoot" something you make a RayCast.

A RayCast it's a ray that has a starting point and continues infinitely in some direction, mathematically speaking. The Raycast will intersect any object within the ray and it will return information about the objects intersected, like how far are they, what type are they, etc..

You can check Pottus Plugin to see an implementation of the RayCast.
Reply
#7

Thanks BlueX, with the info provided i'm sure it is recreatable now.
Reply
#8

Quote:
Originally Posted by Crayder
View Post
AFAIK, not possible in GTA. Therefore, not possible in SA-MP.
Try holding a weapon and go inside the barber shop, and stand infront of the mirror

The mirror makes the weapon disappear, so there must be a way to.
Reply
#9

Quote:
Originally Posted by JaydenJason
View Post
Try holding a weapon and go inside the barber shop, and stand infront of the mirror

The mirror makes the weapon disappear, so there must be a way to.
Lol. The 'mirror' (CULL zone), does not reflect weapons.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)