Galactix
Members-
Posts
121 -
Joined
-
Last visited
-
Days Won
2
Everything posted by Galactix
-
Hello, I made a script that makes a command (/useheroin) which uses the heroin drug and give 200 max hp to the player aswell as Healing him for 60 seconds. However I'm having the issue where if two players use the command in less than 60 seconds, one of them won't get their health set back to 100. --HEROIN DRUG EFFECT ON function heroinDrugOn(player) theDrugPlayer = player setPedStat ( player, 24, 1000) setTimer(heroinDrugOff, 60000,1) setElementHealth(player, 200) triggerClientEvent ( theDrugPlayer, "heroinOnMessage", root) end addCommandHandler("useheroin", heroinDrugOn) --HEROIN DRUG EFFECT GOING OFF function heroinDrugOff(client) local playerHealth = getElementHealth(theDrugPlayer) if (playerHealth > 100) then setPedStat (theDrugPlayer, 24, 590) setElementHealth(theDrugPlayer, 100) else setPedStat (theDrugPlayer, 24, 590) setElementHealth(theDrugPlayer, playerHealth) end triggerClientEvent ( theDrugPlayer, "heroinOffMessage", root) end
-
Thanks, that's good to know!
-
I think I solved my problem, thanks for help! @TheMOG I don't understand what you did there… You just put the function on the serverside part which just does the same as I'm trying to avoid... @maximumdrive Oh, you're right, thanks for that, but on the wiki it was shown like this in the explanation: bool triggerClientEvent ( [table/element sendTo=getRootElement()], string name, element sourceElement, [arguments...] ) Required Arguments name: The name of the event to trigger client side. You should register this event with addEvent and add at least one event handler using addEventHandler. sourceElement: The element that is the source of the event. Event, then element targeted, but on the provided example it is actually how you say, so that's probably a mistake from whom made the page.
-
Hello, I tried using the outputChatBox function on clientside using a triggerClientEvent but it outputs the messages to all online players. Client function heroinDrugOnMessage(theDrugPlayer) outputChatBox("You used heroin.", theDrugPlayer) end addEvent("heroinOnMessage", true) addEventHandler("heroinOnMessage", root, heroinDrugOnMessage) function heroinDrugOffMessage(theDrugPlayer) outputChatBox("The heroin effect has worn off.", theDrugPlayer) end addEvent("heroinOffMessage", true) addEventHandler("heroinOffMessage", root, heroinDrugOffMessage) Server function heroinDrugOn(player) theDrugPlayer = player setPlayerStat ( player, 24, 999) setTimer(heroinDrugOff, 60000,1) setElementHealth(player, 200) triggerClientEvent("heroinOnMessage", player) end addCommandHandler("useheroin", heroinDrugOn) --HEROIN DRUG EFFECT GOING OFF function heroinDrugOff(source,player) local playerHealth = getElementHealth(theDrugPlayer) setPlayerStat (theDrugPlayer, 24, 590) if (playerHealth > 100) then setElementHealth(theDrugPlayer, 100) else setElementHealth(theDrugPlayer, playerHealth) end triggerClientEvent("heroinOffMessage", theDrugPlayer) end
-
Not going to risk into that, I got the result I wanted by doing the way I did so I apreciate your support though SP3CTR3 and Saml1er!
-
Welp, maybe that was the issue then, but that's weird because even when I tried putting all the damage multiplier thingy without adding the condition that solved it into the zombie resource, it just wasn't working either somehow.
-
Thank you for your help everyone. After hours spent trying to get this working I finally came up with a solution using a condition that checks if the damage dealt by the shot is higher than the remaining zombie health, it instantly kills it using killPed and rewards the player, which solved the problem of the damage dealt by setElementHealth being too high and actually making the script unable to detect any attacker.
-
All I want is the zombie to reward the player when it dies, I don't know nor care what event I'm using as long as it does what I want it to do. I've been trying to store values in the ped itself when it gets damaged so that it saves the player name when it gets hit so that when it dies it rewards the last player that hit the zombie gets the reward but I wasn't successful, so at this point I really don't know what to do...
-
UPDATE: It seems that somehow the zombies that aren't considered killed by the player and which don't give any reward seem "alive", like their corpse keeps rotating in the player direction, but not the ones that do reward the player.
-
Exact same problem... I understood your code SP3CTR3 and tried to use it again for the second time, but it only counts less than half the kills I do, and same goes for your script Saml1er, it doesn't do it on every kill, but it does say the message when kills are counted.
-
Yeah I thought about that but how would I make it so that it rewards the player only when the zombie dies and not just when it gets hit?
-
It does like before: sometimes it gives money when the damage dealt isn't too high, but with headshots it just doesn't give any money because the damage is too high. Here's the code I'm using for the dmg multiplier local weaponTable = { -- populate this list by adding weapons: -- [weap_id] = { torso, ass, left_arm, right_arm, left_leg, right_leg, head } [22] = { 1.25, 0.75, 0.75, 0.75, 0.75, 0.75, 1.5}, [23] = { 1.25, 0.75, 0.75, 0.75, 0.75, 0.75, 1.5}, [24] = { 1.25, 0.75, 0.75, 0.75, 0.75, 0.75, 1.5}, [25] = { 1.25, 0.75, 0.75, 0.75, 0.75, 0.75, 1.5}, [26] = { 1.25, 0.75, 0.75, 0.75, 0.75, 0.75, 1.5}, [27] = { 1.25, 0.75, 0.75, 0.75, 0.75, 0.75, 1.5}, [28] = { 1.25, 0.75, 0.75, 0.75, 0.75, 0.75, 1.5}, [29] = { 1.25, 0.75, 0.75, 0.75, 0.75, 0.75, 1.5}, [30] = { 1.25, 0.75, 0.75, 0.75, 0.75, 0.75, 1.5}, [31] = { 1.25, 0.75, 0.75, 0.75, 0.75, 0.75, 1.5}, [32] = { 1.25, 0.75, 0.75, 0.75, 0.75, 0.75, 1.5}, [33] = { 1.25, 0.75, 0.75, 0.75, 0.75, 0.75, 1.5}, [34] = { 1.25, 0.75, 0.75, 0.75, 0.75, 0.75, 1.5} } local weaponDmg = { [22] = {25}, --colt [23] = {40}, --silenced [24] = {70}, --deagle [25] = {10}, --shotgun [26] = {10}, --sawed-off [27] = {15}, --spaz [28] = {20}, --uzi [29] = {25}, --mp5 [30] = {30}, --ak47 [31] = {30}, --m4 [32] = {20}, --tec9 [33] = {75}, --rifle [34] = {125} --sniper rifle } addEvent( "onZombieDamage", true ) function Zheadhit ( ped,attacker, weapon, bodypart) if (getElementData (ped, "zombie") == true) then local bodyPartsDamageTable = weaponTable[ getPedWeapon (attacker) ] local weaponDmgTable = weaponDmg [ getPedWeapon (attacker)] if getElementType(attacker) == "player" and bodyPartsDamageTable then local damageMultiplier = bodyPartsDamageTable [ bodypart - 2] setElementHealth ( ped, getElementHealth(ped) - (damageMultiplier * weaponDmgTable [1] ) ) end end end addEventHandler( "onZombieDamage", getRootElement(), Zheadhit )
-
function deanimated( ammo, attacker, weapon, bodypart ) if (attacker) then if (getElementType ( attacker ) == "player") and (getElementType ( source ) == "ped") then if (getElementData (source, "zombie") == true) then local oldZcount = getElementData ( attacker, "Zombie kills" ) if oldZcount ~= false then setElementData ( attacker, "Zombie kills", oldZcount+1 ) triggerEvent ( "onZombieWasted", source, attacker, weapon, bodypart ) else setElementData ( attacker, "Zombie kills", 1 ) triggerEvent ( "onZombieWasted", source, attacker, weapon, bodypart ) end end end end end addEventHandler("onPedWasted", resourceRoot, deanimated) This function is the one that trigger the event
-
Hello, I am using a zombie script and I started using a damage multiplier resource that uses the setElementHealth function. The problem is that now my zombies do not give money at death anymore as the game doesn't consider that a player killed the ped. I'm using this code to reward money at zombie death: addEvent("onZombieWasted",true) addEventHandler("onZombieWasted",root, function (attacker) givePlayerMoney(attacker,math.random(75,150)) -- default 50$ end) Is there any kind of variable or function that would allow me to give money to the last person that hit the zombie before it dies?
-
Hello, I'm trying to make a script to reload weapons but I can't get it working function weaponReload() local wep = getPlayerWeapon ( localPlayer ) setWeaponClipAmmo(wep, 7) end addCommandHandler("reload", weaponReload) I tried this to reload my desert eagle but it outputs the following error : I don't really see what else than the weapon ID I could use that expected weapon error Anyone knows how to fix it? EDIT: After further research it turns out there was a built-in resource in the MTA files, problem solved
-
Actually, I'm getting this error now [21:23:31] ERROR: [OutbreakRPG]\zdamage\damage_server.lua:15: attempt to perform arithmetic on global 'bodyPart' (a nil value) How to fix it? EDIT: Changed "bodyPart" to "bodypart" and it's now solved and working completely, thanks a lot again!
-
I tried running your script but it doesn't seem to affect the damage I deal to the zombies with the deagle, even after modifying the multiplier in the damage_config.xml file. Is the script intended to modify damage dealt to player elements or peds aswell?
-
Hello, I am Scripting a zombie rpg server and as I disabled headshot kills on zombies, I would like to make a damage multiplier system depending on the body part hit when you shoot a zombie. I have been trying to use this script (not mine): local weaponTable = { -- populate this list by adding weapons: -- [weap_id] = { torso, ass, left_arm, right_arm, left_leg, right_leg, head } [24] = { 75, 50, 30, 30, 25, 25, 150 }, } addEventHandler("onPlayerDamage", getRootElement(), function (attacker, weapon, bodypart, loss) if getElementType(attacker) == "player" and getPlayerWeapon(attacker) and weaponTable[ getPlayerWeapon(attacker) ] then setElementHealth(source, getElementHealth(source) - weaponTable[ getPlayerWeapon(attacker) ] [ bodyPart - 2] + loss) end end ) but it didn't work on both players and zombie peds. If someone has a solution for this to work the way I want it would be great (ideally both player and zombie ped multiplier but ped multiplier is more important)