Baseplate Posted June 10, 2011 Share Posted June 10, 2011 Hey all I want some help of the Tazer for the LSPD team please help me Link to comment
Castillo Posted June 10, 2011 Share Posted June 10, 2011 We can't help you to fix something if you don't post your code. Link to comment
JR10 Posted June 10, 2011 Share Posted June 10, 2011 i think he wants the script itself not to fix it -.- you cant just come asking for a script try it first and post ur problems Link to comment
Dark Dragon Posted June 10, 2011 Share Posted June 10, 2011 Hello, you might have noticed by now, but people here generally don't like to help you if you haven't put any effort into getting something done yet. If you need help on how to script in general the wiki's introduction to scripting might help you https://wiki.multitheftauto.com/wiki/Scr ... troduction Once you actually have something to show us and ask for help on a specific aspect people will likely be to help you in no time! Greetings! Link to comment
JR10 Posted June 10, 2011 Share Posted June 10, 2011 well i will just tell you what u can do setPedAnimation(tazer, block, anim) -- to make him look like tazing someone setPedFrozen(tazed, true) -- to make the tazed ped frozen not sure if this is nescessary setPedAnimation(tazed, block, anim) -- to make him look like tazed Link to comment
Baseplate Posted June 13, 2011 Author Share Posted June 13, 2011 hmm oK I'll post the code Client-side: cooldown = 0 cooldownTimer = nil localPlayer = getLocalPlayer() --function isPD() -- return exports.factions:isPlayerInFaction( localPlayer, 1 ) --end function switchMode() if (getPedWeapon(localPlayer)==24) and (getPedTotalAmmo(localPlayer)>0) then -- has ammo local mode = getElementData(localPlayer, "silencedmode") if mode == 0 then -- tazer mode triggerServerEvent("silencedmode", localPlayer, localPlayer, 1) outputChatBox( "You switched your weapon mode to lethal.", 0, 255, 0 ) elseif mode == 1 -- and isPD() then -- lethal mode outputChatBox( "You switched your weapon to radar gun.", 0, 255, 0 ) triggerServerEvent("silencedmode", localPlayer, localPlayer, 2) elseif mode == 2 or mode == 1 then -- radar gun mode outputChatBox( "You switched your weapon to taser.", 0, 255, 0 ) triggerServerEvent("silencedmode", localPlayer, localPlayer, 0) end end end function bindKeys(res) bindKey("n", "down", switchMode) local mode = getElementData(localPlayer, "silencedmode") if not (mode) then triggerServerEvent("silencedmode", localPlayer, localPlayer, 0) end end addEventHandler("onClientResourceStart", getResourceRootElement(), bindKeys) function enableCooldown() cooldown = 1 cooldownTimer = setTimer(disableCooldown, 3000, 1) toggleControl("fire", false) setElementData(getLocalPlayer(), "silenced:reload", true) end function disableCooldown() cooldown = 0 toggleControl("fire", true) setElementData(getLocalPlayer(), "silenced:reload", false) if (cooldownTimer~=nil) then killTimer(cooldownTimer) cooldownTimer = nil end end addEventHandler("onClientPlayerWeaponSwitch", getRootElement(), disableCooldown) function weaponFire(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) if (weapon==24) then -- silenced local mode = getElementData(localPlayer, "silencedmode") if (mode==0) then -- tazer mode enableCooldown() local px, py, pz = getElementPosition(localPlayer) local distance = getDistanceBetweenPoints3D(hitX, hitY, hitZ, px, py, pz) if (distance<35) then fxAddSparks(hitX, hitY, hitZ, 1, 1, 1, 1, 10, 0, 0, 0, true, 3, 1) end playSoundFrontEnd(38) triggerServerEvent("tazerFired", localPlayer, hitX, hitY, hitZ, hitElement) end end end addEventHandler("onClientPlayerWeaponFire", localPlayer, weaponFire) function weaponAim(target) if (target) then if (getElementType(target)=="vehicle") then if (getPedWeapon(localPlayer)==24) then local mode = getElementData(localPlayer, "silencedmode") if (mode==2) then actualspeed = exports.global:getVehicleVelocity(target) outputChatBox(getVehicleName(target) .. " clocked in at " .. actualspeed .. " km/h.", 255, 194, 14) end end end end end addEventHandler("onClientPlayerTarget", getRootElement(), weaponAim) -- code for the target/tazed person function cancelTazerDamage(attacker, weapon, bodypart, loss) if (weapon==24) then -- silenced local mode = getElementData(attacker, "silencedmode") if (mode==0 or mode==2) then -- tazer mode / radar gun mode cancelEvent() end end end addEventHandler("onClientPlayerDamage", localPlayer, cancelTazerDamage) function showTazerEffect(x, y, z) fxAddSparks(x, y, z, 1, 1, 1, 1, 100, 0, 0, 0, true, 3, 2) playSoundFrontEnd(38) end addEvent("showTazerEffect", true ) addEventHandler("showTazerEffect", getRootElement(), showTazerEffect) local underfire = false local fireelement = nil local localPlayer = getLocalPlayer() local originalRot = 0 local shotsfired = 0 function onTargetPDPed(element) if (isElement(element)) then if (getElementType(element)=="ped") and (getElementModel(element)==282 or getElementModel(element)==280 or getElementModel(element)==285) and not (underfire) and (getControlState("aim_weapon")) then underfire = true fireelement = element originalRot = getPedRotation(element) addEventHandler("onClientRender", getRootElement(), makeCopFireOnPlayer) addEventHandler("onClientPlayerWasted", getLocalPlayer(), onDeath) end end end addEventHandler("onClientPlayerTarget", getLocalPlayer(), onTargetPDPed) function makeCopFireOnPlayer() if (underfire) and (fireelement) then local rot = getPedRotation(localPlayer) local x, y, z = getPedBonePosition(localPlayer, 7) setPedRotation(fireelement, rot - 180) setPedControlState(fireelement, "aim_weapon", true) setPedAimTarget(fireelement, x, y, z) setPedControlState(fireelement, "fire", true) shotsfired = shotsfired + 1 -- if (shotsfired>40) then -- triggerServerEvent("killmebyped", getLocalPlayer(), fireelement) -- end end end function onDeath() if (fireelement) and (underfire) then setPedControlState(fireelement, "aim_weapon", false) setPedControlState(fireelement, "fire", false) setPedRotation(fireelement, originalRot) fireelement = nil underfire = false removeEventHandler("onClientRender", getRootElement(), makeCopFireOnPlayer) removeEventHandler("onClientPlayerWasted", getLocalPlayer(), onDeath) end end Server-side: local time = 10 --In seconds, time, when player is frozen function silencedmodes(localPlayer, number) local mode = tonumber(number) if mode == 0 then --tazer setElementData(localPlayer,"silencedmode", 0) elseif mode == 1 then --leathal setElementData(localPlayer,"silencedmode", 1) elseif mode ==2 then --radar setElementData(localPlayer,"silencedmode", 2) end end addEvent("silencedmode", true) addEventHandler("silencedmode", getRootElement(), silencedmodes, thePlayer, number) function tazerShot(hitX, hitY, hitZ, hitElement) setPedFrozen ( source, true ) setPedAnimation( source, "ped", "FLOOR_hit_f") setTimer(setPedFrozen, time * 1000, 1, source, false) setTimer(setPedAnimation, time * 1000, 1, source) end addEvent("tazerFired", true) addEventHandler("tazerFired", getRootElement(), tazerShot, hitX, hitY, hitZ, hitElement) function killmebyped(target) --killed by ped blahhhh end When I turn it to Tazer and shoot someone I get down tazzered not that I shooted him Link to comment
Jaysds1 Posted June 14, 2011 Share Posted June 14, 2011 What's the problem? is there any error code or does the script not work? Link to comment
Baseplate Posted June 14, 2011 Author Share Posted June 14, 2011 hmm no error but when I play and shoot someone with the Tazer I get down with the Tazzing animation and that who I shooted him dosen't happen nothing to him Link to comment
JR10 Posted June 14, 2011 Share Posted June 14, 2011 addEventHandler("silencedmode", getRootElement(), silencedmodes, thePlayer, number) function tazerShot(hitX, hitY, hitZ, hitElement) Why you are putting arguments in add event handler , Syntax: bool addEventHandler ( string eventName, element attachedTo, function handlerFunction, [bool getPropagated = true] ) function tazerShot(hitX, hitY, hitZ, hitElement) setPedFrozen ( source, true ) setPedAnimation( source, "ped", "FLOOR_hit_f") setTimer(setPedFrozen, time * 1000, 1, source, false) setTimer(setPedAnimation, time * 1000, 1, source) end I don't know where the source is defined it should be client but i think from what i read in your script it should be like this addEvent("silencedmode", true) addEventHandler("silencedmode", getRootElement(), silencedmodes, thePlayer, number) function tazerShot(hitX, hitY, hitZ, hitElement) setPedFrozen ( hitElement, true ) setPedAnimation( hitElement, "ped", "FLOOR_hit_f") setTimer(setPedFrozen, time * 1000, 1, hitElement, false) setTimer(setPedAnimation, time * 1000, 1, hitElement) end Link to comment
Phat Looser Posted June 14, 2011 Share Posted June 14, 2011 You should start the debug console and RESTART the script so you can see whats going on on client resource start. I guess th event handlers aren't even working like JR10 said. Link to comment
Baseplate Posted June 14, 2011 Author Share Posted June 14, 2011 SO Jr10 can you post the full codes? Link to comment
JR10 Posted June 14, 2011 Share Posted June 14, 2011 So you can just copy and paste it? no. I told you what you got wrong and you must fix it yourself. -.- Link to comment
Orange Posted June 14, 2011 Share Posted June 14, 2011 Check my old resource: https://community.multitheftauto.com/index.php?p= ... ils&id=529 Just change the weapon from Deagle to a weaker one Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now