ice_brasil Posted May 15, 2013 Share Posted May 15, 2013 function timeCheck() local hh, mm = getTime() if (hh<7) then local ww, bb = getWeather() if (ww ~= -52123) then setWeather(-52123) end else local ww, bb = getWeather() if (ww ~= 190) then setWeather(190) end end end function fall() if (isDrugActive) then setPedAnimation(getLocalPlayer(), "ped", "getup_front",2500, false, false) setTimer(function() fall() end, math.random(10000, 30000), 1) setTimer(function() setControlState ('jump',true) end, 2500, 1) setTimer(function() setControlState ('jump',false) end, 3000, 1) end end function addRednessOnDamage ( ) fadeCamera ( source, false, 1.0, 255, 0, 0 ) -- fade the player's camera to red over a period of 1 second setTimer ( fadeCamera, 1500, 1, source, true, 0.5 ) -- don't let it go to opaque red, interrupt it after half a second and fade back to normal end addEventHandler("onClientRender", getRootElement(), drugSteer) addEventHandler("onClientPreRender", getRootElement(), drugCam) function drugSteer() left=false right=false up=false down=false local keys = getBoundKeys ('vehicle_left') if keys then tmpLeft = false for keyName, state in pairs(keys) do if (getKeyState(keyName)) then tmpLeft=true end end if tmpLeft then left=true right=false end end local keys = getBoundKeys ('vehicle_right') if keys then tmpRight = false for keyName, state in pairs(keys) do if (getKeyState(keyName)) then tmpRight=true end end if tmpRight then left=false right=true end end if (left) then setControlState('vehicle_left', false) setControlState('vehicle_right', true) elseif (right) then setControlState('vehicle_right', false) setControlState('vehicle_left', true) else setControlState('vehicle_right', false) setControlState('vehicle_left', false) end if (left) then setControlState('ped_left', true) setControlState('ped_right', true) elseif (right) then setControlState('ped_right', false) setControlState('ped_left', true) else setControlState('ped_right', true) setControlState('ped_left', true) end local keys = getBoundKeys ('accelerate') if keys then tmpUp = false for keyName, state in pairs(keys) do if (getKeyState(keyName)) then tmpUp=true end end if tmpUp then down=false up=true end end local keys = getBoundKeys ('brake_reverse') if keys then tmpDown = false for keyName, state in pairs(keys) do if (getKeyState(keyName)) then tmpDown=true end end if tmpDown then down=true up=false end end if (up) then setControlState('accelerate', true) setControlState('brake_reverse', false) elseif (down) then setControlState('brake_reverse', true) setControlState('accelerate', false) else setControlState('brake_reverse', false) setControlState('accelerate', true) end end function startDrug(time) setTimer(function(time) if (time == nil) then time = 10*1000 else if (tonumber(time) < 5000) then tiaaame = 10*1000 end end timerWeather = setTimer(function() timeCheck() end, 1000) timerFades = setTimer(function() fades() end, 4000) isDrugActive = true setTimer(function() fall() end, 1000, 1) addEventHandler("onClientRender", getRootElement(), drugSteer) addEventHandler("onClientPreRender", getRootElement(), drugCam) setTimer(function() stopDrug() end, time, 1) end, 1500, 1, time) end function stopDrug() killTimer(timerFades) killTimer(timerWeather) isDrugActive = false removeEventHandler("onClientRender", getRootElement(), drugSteer) removeEventHandler("onClientPreRender", getRootElement(), drugCam) triggerServerEvent("restoreWeather", getLocalPlayer()) setTimer(function() setCameraTarget(getLocalPlayer()) end, 2500, 1) end function startDrug2() startDrug(4) end function stopDrug2() stopDrug() end addCommandHandler("sd", startDrug2) addCommandHandler("sds", stopDrug2) function restoreWeather(ww) setWeather(ww) end addEvent("restoreWeather", true) addEventHandler("restoreWeather", getRootElement(), restoreWeather) function missionStart(whichMouse, state, absoluteX, absoluteY) local number = getElementData(source,"number") -- this is the button "id" local money=getPlayerMoney(getLocalPlayer()) if (number=='a') then if (money>=500) then startDrug(1*60*1000) triggerServerEvent("takeMoney", getLocalPlayer(),500) else outputChatBox("Você não tem dinheiro!", 255, 0, 0) end elseif (number=='b') then if (money>=1000) then startDrug(3*60*1000) triggerServerEvent("takeMoney", getLocalPlayer(),1000) else outputChatBox("Você não tem dinheiro!", 255, 0, 0) end elseif (number=='c') then if (money>=1500) then startDrug(6*60*1000) triggerServerEvent("takeMoney", getLocalPlayer(),1500) else outputChatBox("Você não tem dinheiro!", 255, 0, 0) end else if (money>=2000) then startDrug(10*60*1000) triggerServerEvent("takeMoney", getLocalPlayer(),2000) else outputChatBox("Você não tem dinheiro!", 255, 0, 0) end end --outputChatBox("#00ff00\"dfdf\" #ffffff started!",255,255,255,true) guiSetVisible (missionSelectWindow1, false) showCursor (false) end -- this fires when player hits the marker function missionSelect(hitPlayer, matchingDimension) if (hitPlayer == getLocalPlayer()) and (isPedOnGround (getLocalPlayer()) and not isPedInVehicle(hitPlayer)) then if isDrugActive then outputChatBox("Você esta drogado,você quer morrer ?!", 255, 0, 0) else guiSetVisible (missionSelectWindow1, true) guiBringToFront (missionSelectWindow1) showCursor (true) end end end function guiCancel () guiSetVisible (missionSelectWindow1, false) showCursor (false) end addEventHandler ("onClientResourceStart", getResourceRootElement(getThisResource()), function() local missionElements = getElementsByType ("drugstore", getResourceRootElement(getThisResource())) num=0 drugMarker = { } drugSphere = { } drugBlip = { } for key,val in ipairs(missionElements) do num=num+1 local tmpX= getElementData(val, "posX") local tmpY= getElementData(val, "posY") Link to comment
xXMADEXx Posted May 15, 2013 Share Posted May 15, 2013 Try this.. function addRednessOnDamage ( ) fadeCamera ( source, false) p = source setTimer ( function () fadeCamera(p,true) end, 5000, 1, source) end addEventHandler ( "onPlayerDamage", getRootElement(), addRednessOnDamage ) Link to comment
ice_brasil Posted May 15, 2013 Author Share Posted May 15, 2013 you not understand the fadecamera the works! but I want to be When You click the button on my script to activate the function of fadecamera not know what function! Link to comment
xXMADEXx Posted May 16, 2013 Share Posted May 16, 2013 you not understand the fadecamera the works! but I want to be When You click the button on my script to activate the function of fadecamera not know what function! Your English is to hard for me to understand. But, i think this is what yoru asking for. Server: function addRednessOnDamage ( ) fadeCamera ( source, false) p = source setTimer ( function () fadeCamera(p,true) end, 5000, 1, source) end addEvent("addRednessOnDamage", true) addEventHandler ( "addRednessOnDamage", root, addRednessOnDamage) Client: addEventHandler("onClientGUIClick", root, -- Make sure to replace "root" with the button variable. function () triggerServerEvent ( "addRednessOnDamage", source) end ) Link to comment
PaiN^ Posted May 16, 2013 Share Posted May 16, 2013 (edited) addEventHandler("onClientGUIClick", root, -- Make sure to replace "root" with the button variable. function () triggerServerEvent ( "addRednessOnDamage", localPlayer) end, false ) Edited May 16, 2013 by Guest Link to comment
PaiN^ Posted May 16, 2013 Share Posted May 16, 2013 oh yeh, I only fixed the false thing Edited ! Link to comment
iPrestege Posted May 16, 2013 Share Posted May 16, 2013 @ ice_brasil Are sure about the weather id ? At line 6 . Link to comment
Tete omar Posted May 17, 2013 Share Posted May 17, 2013 ice_brasil, setWeather function will simply return false and here is the reasons: Required Arguments weatherID: The new weather id. Valid values are 0 to 255 inclusive. Returns Returns true if the weather was set succesfully, false if an invalid weatherID was specified. 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