English NPC's Parametres

8 replies
Goto Page
To the start Previous 1 Next To the start
16.12.18 09:57:27 pm
Up
tos12345678
User
Offline Off
I have question.
Whether there is a script which:
Will drop others money from each other npc's (after kill npc) e.g.
Zombies:
Code:
1
parse("spawnitem 66 "..object(id,"tilex").." "..object(id,"tiley"))

Soliders:
Code:
1
parse("spawnitem 68 "..object(id,"tilex").." "..object(id,"tiley"))

Please help me with this script if it's possible. Thanks!
17.12.18 08:09:08 pm
Up
Quattro
User
Offline Off
there is lua hook for kill and death.
get npc's coordinates of the victim using function for one of these hooks and spawn gold with the parse line you wrote
17.12.18 11:12:36 pm
Up
tos12345678
User
Offline Off
Good idea.
18.12.18 03:51:49 am
Up
Joni And Friends
User
Online On
You can use cs2d lua hook objectdamage To get object ID and check possition the object by using cs2d lua cmd object and use cs2d lua hook objectkill to drop the item at object possition
Web | file File does not exist (15501) | file File does not exist (15463) | file cs2d [JAF] Adventure (19) | file File does not exist (15919)
18.12.18 12:12:40 pm
Up
Avo
User
Offline Off
Code:
1
2
3
4
5
6
7
8
addhook('objectkill', 'onObjectKill')
function onObjectKill(oid, pid)
     if object(oid, 'player') == 1 then -- zombie
          parse("spawnitem 66 "..object(oid,"tilex").." "..object(oid,"tiley"))
     elseif object(oid, 'player') == 5 then -- soldier
          parse("spawnitem 68 "..object(oid,"tilex").." "..object(oid,"tiley"))
     end
end


I don't really remember if object's position is available at the moment of being destroyed, so the above might not work. In that case try this one:

Code:
1
2
3
4
5
6
7
8
9
10
addhook('objectdamage', 'onObjectDamage')
function onObjectKill(oid, dmg, src)
     if dmg >= object(oid, 'health') then
          if object(oid, 'player') == 1 then -- zombie
               parse("spawnitem 66 "..object(oid,"tilex").." "..object(oid,"tiley"))
          elseif object(oid, 'player') == 5 then -- soldier
               parse("spawnitem 68 "..object(oid,"tilex").." "..object(oid,"tiley"))
          end
     end
end


cs2d lua cmd object, cs2d lua hook objectkill, cs2d lua hook objectdamage
edited 1×, last 18.12.18 04:42:16 pm
18.12.18 01:35:18 pm
Up
tos12345678
User
Offline Off
Lua error
'object damage' params 1, 24, 1
edited 2×, last 18.12.18 02:23:39 pm
18.12.18 04:43:08 pm
Up
Avo
User
Offline Off
There was a typo, fixed that for you.
18.12.18 10:54:20 pm
Up
Quattro
User
Offline Off
yeah it should work, I was using these commands in aim challenge script too. my image object was called HUD:

Code:
1
2
parse('sv_soundpos "/2DMasters/training/splash.ogg" '..object(HUD,'x')..' '..object(HUD,'y')..'')
    parse('sv_soundpos "/2DMasters/training/'..name..'" '..object(HUD,'x')..' '..object(HUD,'y')..'')
30.12.18 01:32:50 pm
Up
tos12345678
User
Offline Off
Thank you, it's working
To the start Previous 1 Next To the start