0 registered members (),
1,397
guests, and 7
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
gun code
#71686
04/20/06 22:39
04/20/06 22:39
|
Joined: Dec 2005
Posts: 252 MyOwnKingdom
nipx
OP
Member
|
OP
Member
Joined: Dec 2005
Posts: 252
MyOwnKingdom
|
Hi all! I try to write a code for my gun. And now I have a problem with my code(what else? ) If press <ctrl> for shot, not the ball moves but my gun! Plz help me! Code:
function fWeapon_fire() I think it s correct... { Weapon_fire=1; while(key_ctrl==1 || mouse_left==1){wait(1);} Weapon_fire=0; }
function fShoot(shot_speed,shot_gravity) {
while(1) { c_move(me,vector(0,shot_speed*time,0),vector(0,0,shot_gravity*time),ignore_models);Here is my bug....? shot_gravity-=0.05; wait(1); } }
action aPlayer { ePlayer=me; my._health=100; my._shot_damage=25; my._shot_speed=85; my._shot_gravity=-0.1; my._shots_per_sec=3; var shot_speed; var shot_gravity; while(1) { if(Weapon_fire==1) { ent_create(sShot, vector(my.x+65,my.y, my.z+5),fShoot(my._shot_speed,my._shot_gravity)); or is it here...? } sleep(1/my._shots_per_sec); } }
thx nipx PS: plz dont deride my code, I'm still a newbie!
Last edited by nipx; 04/21/06 01:51.
|
|
|
Re: gun code
[Re: nipx]
#71687
04/21/06 21:16
04/21/06 21:16
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
c_move(me,vector(0,shot_speed*time,0),vector(0,0,shot_gravity*time),ignore_models); - - - should be - - - c_move(me,vector(my._shot_speed*time,0,0),vector(0,0,my._shot_gravity*time),ignore_models); I'm not sure if you can assign a function to an entity, so try this... Code:
action fShoot { my.enable_impact = on; my.event = fShootEvent; while(my != null) { c_move(me, vector(0, my._shot_speed * time, 0), vector(0, 0, my._shot_gravity * time), ignore_models); my._shot_gravity -= 0.05; wait(1); } }
function fShootEvent() { if (event_type == event_impact) { my.event = null; wait(1); ent_remove(me); } }
... temp.x = 65; temp.y = 0; temp.z = 5; vec_rotate(temp.x, my.pan); vec_add(temp.x, my.x); you = ent_create(sShot, temp.x, fShoot); you._shot_speed = my._shot_speed; you._shot_gravity = my._shot_gravity; ...
xXxGuitar511 - Programmer
|
|
|
Re: gun code
[Re: nipx]
#71690
04/23/06 05:54
04/23/06 05:54
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
Glad to help... thats kool if you can put me (Josh Miller) in credits, but if not, i dont care...
xXxGuitar511 - Programmer
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|