English Kill with granate...

14 replies
Goto Page
To the start Previous 1 Next To the start
11.11.11 10:44:14 am
Up
Sudden Death
User
Offline Off
Hello i try to make script, and i got problem <look title>
here script:
Code:
1
2
3
4
5
6
7
8
addhook("die","killexp")
function killexp(id,killer,weapon)
exp[killer]=exp[killer]+100
if player(killer,"weapon")==51 then
exp[killer]=exp[killer]+50
msg2(killer,"©250000000Killed with granate! Bonus 50exp!")
end
end

and whats don't work: when i kill with he then i don't have that granate, and script think i kill with knife i think that should be no if player weapon but weapon with what player kill, but no idea how to write it ::
plis help
Sniffin'Man "If it cannot be done with lua, it must be you mama, coz she's too fat"
11.11.11 01:40:09 pm
Up
Surplus
User
Offline Off
Code:
1
2
3
4
5
6
7
8
9
10
11
addhook("die","killexp")
     function killexp(id,killer,weapon)
          if player(killer,"weapon")==51 then
               exp[killer]=exp[killer]+150
               msg2(killer,"©250000000Killed with grenade! Bonus 50exp!")
          end
          elseif player(killer,"weapon")~=51 then
               exp[killer]=exp[killer]+100
          end
     return 0
end


Might work. Prob. Wrong
11.11.11 01:58:49 pm
Up
Sudden Death
User
Offline Off
Yep, don't work still think killed with knife.
Sniffin'Man "If it cannot be done with lua, it must be you mama, coz she's too fat"
11.11.11 02:21:05 pm
Up
Surplus
User
Offline Off
Just asking, do you even have a exp system? Or this is the whole code you got?
11.11.11 04:09:38 pm
Up
Sudden Death
User
Offline Off
Look at priv message.
Sniffin'Man "If it cannot be done with lua, it must be you mama, coz she's too fat"
11.11.11 04:37:41 pm
Up
EngiN33R
Moderator
Offline Off
Code:
1
2
3
4
5
6
7
8
9
10
11
addhook("die","killexp")
     function killexp(id,killer,weapon)
          if weapon==51 then
               exp[killer]=exp[killer]+150
               msg2(killer,"©250000000Killed with grenade! Bonus 50exp!")
          end
          else
               exp[killer]=exp[killer]+100
          end
     return 0
end


No?
I code, therefore I exist. | Visit my blog for Lua tips and other interesting info
11.11.11 06:44:08 pm
Up
DarkLight66
User
Offline Off
im not sure but maybe you need to use the "kill" hook, did you tried with it?
Paradox
11.11.11 07:10:08 pm
Up
Sudden Death
User
Offline Off
@Engin33r no no no you think bad, its same what write PartyPooPer, its got problem when player throw he granade then he lose it, script see player got knife and when player is killed then got bonus point for killing with knife

@DarkLight66 Yes, I try but then lua don't work like what i want :l

Edit: Don't waste your time guys i try to make it myself
Sniffin'Man "If it cannot be done with lua, it must be you mama, coz she's too fat"
15.11.11 09:54:27 pm
Up
troctor
User
Offline Off
> I DONT KNOW IF YOU ALREADY SOLVED IT

Well.. try with this..

I replaced this things:

(I dont know if this is really necessary, but i always put the original parameters)
Function fix has written:
function killexp(id,killer,weapon)

To

function killexp(victim,killer,weapon,x,y)

------------------------------------

Now you won't use "id" you will use "victim" (That is the guy who died)



(I think this make all your problems)
Killer ERROR fix has written:
if player(killer,"weapon")==51 then

To

if weapon==51 then

------------------------------------

The problem is that in the parameters you ALREADY have "weapon" so you only need to put weapon==51 and it will take it that the killer weapon.
The problem with "weapontype" is because when u fire the grenade, you get setted the knife, and when the lua watches your weapontype (when you dont have the grenade because you fired it) you have the knife and it reads it like weapon==50.


Now try with this:

Code:
1
2
3
4
5
6
7
8
addhook("die","killexp")
function killexp(victim,killer,weapon,x,y)
     exp[killer]=exp[killer]+100
     if weapon==51 then
          exp[killer]=exp[killer]+50
          msg2(killer,"©250000000Killed with granade! Bonus 50exp!")
     end
end


Quote:
ATTENTION: Remember that the word is "grenade" not "grenate"


I deleted the "exp" things to test it, and it works well with the grenade, i hope it works for you

Tell me how it works
edited 1×, last 16.11.11 12:59:14 am
IMG:http://files.myopera.com/Gaturronik/albums/7027902/Troctor%20cs2dplayer.png
16.11.11 05:25:38 am
Up
PyKemis
User
Offline Off
Why not use the kill hook instead?

Code:
1
2
3
4
5
6
7
8
9
addhook("kill","_kill")

function _kill(killer,victim,weapon)
     exp[killer]=exp[killer]+100
     if weapon==51 then
          exp[killer]=exp[killer]+50
          msg2(killer,"©250000000Killed with grenade! Bonus 50exp!")
     end
end


Oh and PartyPooper, you ended the if statement, so you can't use else :).
16.11.11 07:22:15 am
Up
Sudden Death
User
Offline Off
Yeah, Troctor fix it big thx
Textual Context: no, die hook is fine
Sniffin'Man "If it cannot be done with lua, it must be you mama, coz she's too fat"
16.11.11 07:26:06 am
Up
PyKemis
User
Offline Off
So reverse the logic.

Code:
1
2
3
4
5
6
7
8
9
addhook("die","killexp")

function killexp(victim,killer,weapon)
     exp[killer]=exp[killer]+100
     if weapon==51 then
          exp[killer]=exp[killer]+50
          msg2(killer,string.char(169).."250000000Killed with grenade! Bonus 50exp!")
     end
end


The reason your script fails is because you're checking the killer's weapon after he throws the grenade-the weapon is most likely the knife or the primary weapon.

If you check the weapon that the death was caused by it should work.
16.11.11 08:02:18 am
Up
EngiN33R
Moderator
Offline Off
Derp, I wrote exactly what Troctor wrote and was told that it was incorrect? What the hell man? Are you blind or stupid?
I code, therefore I exist. | Visit my blog for Lua tips and other interesting info
16.11.11 08:58:25 pm
Up
Sudden Death
User
Offline Off
@user EngiN33R: Maybe I am stupid, but you make toooooo much code for me @user troctor: make only 3 lines what i need :X
anyway, please no new post
Sniffin'Man "If it cannot be done with lua, it must be you mama, coz she's too fat"
16.11.11 09:07:03 pm
Up
EngiN33R
Moderator
Offline Off
user Sudden Death has written:
you make toooooo much code for me


I copy-pasted your original code with my fix. Too much? Nope.
I code, therefore I exist. | Visit my blog for Lua tips and other interesting info
To the start Previous 1 Next To the start