CrazyDude69 Posted January 14, 2010 Share Posted January 14, 2010 Hi everyone, look at my script: http://mta.pastebay.com/82749 Why the hell, when player spawns, keys not binding? If i trigerring this function with addCommandHandler, everything is ok, but if i trigerring this with addEventHandler, nothing happens, and this is client side script, and /debugscript 3 don't see errors or warning :\ And rootElement = getRootElement() Link to comment
CrazyDude69 Posted January 14, 2010 Author Share Posted January 14, 2010 Hi everyone, look at my script: http://mta.pastebay.com/82749 Why the hell, when player spawns, keys not binding? If i trigerring this function with addCommandHandler, everything is ok, but if i trigerring this with addEventHandler, nothing happens, and this is client side script, and /debugscript 3 don't see errors or warning :\ And rootElement = getRootElement() Link to comment
50p Posted January 14, 2010 Share Posted January 14, 2010 Is the event triggered? Tried to debug it? Make sure player spawned is local player otherwise you'll keep binding keys every time anyone spawns. BTW, you can post such scripts here: [lua]your code here[/lua]. Link to comment
50p Posted January 14, 2010 Share Posted January 14, 2010 Is the event triggered? Tried to debug it? Make sure player spawned is local player otherwise you'll keep binding keys every time anyone spawns. BTW, you can post such scripts here: [lua]your code here[/lua]. Link to comment
zorrigas Posted January 14, 2010 Share Posted January 14, 2010 the code will not have problems, remember that it ClientSide (type="client") and this event is triggered when any player spawns and must have a function with projectile. You can also use ServerSide which only activated for the player onPlayerSpawn Link to comment
zorrigas Posted January 14, 2010 Share Posted January 14, 2010 the code will not have problems, remember that it ClientSide (type="client") and this event is triggered when any player spawns and must have a function with projectile. You can also use ServerSide which only activated for the player onPlayerSpawn Link to comment
CrazyDude69 Posted January 14, 2010 Author Share Posted January 14, 2010 the code will not have problems, remember that it ClientSide (type="client") and this event is triggered when any player spawns and must have a function with projectile.You can also use ServerSide which only activated for the player onPlayerSpawn I have function projectile, just don't posted it, this function works, so problem don't in it :\ Link to comment
CrazyDude69 Posted January 14, 2010 Author Share Posted January 14, 2010 the code will not have problems, remember that it ClientSide (type="client") and this event is triggered when any player spawns and must have a function with projectile.You can also use ServerSide which only activated for the player onPlayerSpawn I have function projectile, just don't posted it, this function works, so problem don't in it :\ Link to comment
ThePope Posted January 15, 2010 Share Posted January 15, 2010 where is rootElement comming from? function bindTheKeys() unbindKey("mouse1", "down") bindKey("mouse1", "down", projectile) end addEventHandler ( "onClientPlayerSpawn", >>> rootElement <<<, bindTheKeys ) Link to comment
ThePope Posted January 15, 2010 Share Posted January 15, 2010 where is rootElement comming from? function bindTheKeys() unbindKey("mouse1", "down") bindKey("mouse1", "down", projectile) end addEventHandler ( "onClientPlayerSpawn", >>> rootElement <<<, bindTheKeys ) Link to comment
zorrigas Posted January 15, 2010 Share Posted January 15, 2010 rootElement = getRootElement() function bindTheKeys() unbindKey("mouse1", "down") bindKey("mouse1", "down", projectile) end addEventHandler ( "onClientPlayerSpawn", rootElement, bindTheKeys ) rootElement = getRootElement() on top of you script! Link to comment
zorrigas Posted January 15, 2010 Share Posted January 15, 2010 rootElement = getRootElement() function bindTheKeys() unbindKey("mouse1", "down") bindKey("mouse1", "down", projectile) end addEventHandler ( "onClientPlayerSpawn", rootElement, bindTheKeys ) rootElement = getRootElement() on top of you script! Link to comment
50p Posted January 15, 2010 Share Posted January 15, 2010 If only both of you zorrigas and ThePope have ever read the first message you'd know Hi everyone, look at my script: http://mta.pastebay.com/82749Why the hell, when player spawns, keys not binding? If i trigerring this function with addCommandHandler, everything is ok, but if i trigerring this with addEventHandler, nothing happens, and this is client side script, and /debugscript 3 don't see errors or warning :\ And rootElement = getRootElement() @CrazyDude69, bindKey has always been pain in the butt in onClientPlayerSpawn, onPlayerSpawn, onPlayerJoin and onResourceStart. These are the events I've experienced this problem since DP1. Try to make a delay. Let the player spawn, set a timer for 1 second which will bind their key. Link to comment
50p Posted January 15, 2010 Share Posted January 15, 2010 If only both of you zorrigas and ThePope have ever read the first message you'd know Hi everyone, look at my script: http://mta.pastebay.com/82749Why the hell, when player spawns, keys not binding? If i trigerring this function with addCommandHandler, everything is ok, but if i trigerring this with addEventHandler, nothing happens, and this is client side script, and /debugscript 3 don't see errors or warning :\ And rootElement = getRootElement() @CrazyDude69, bindKey has always been pain in the butt in onClientPlayerSpawn, onPlayerSpawn, onPlayerJoin and onResourceStart. These are the events I've experienced this problem since DP1. Try to make a delay. Let the player spawn, set a timer for 1 second which will bind their key. Link to comment
CrazyDude69 Posted January 15, 2010 Author Share Posted January 15, 2010 Oh, i get why keys don't binding, the problem in "play" gamemode, for let them bind, i must first die, and after respawn, everything will be ok Link to comment
CrazyDude69 Posted January 15, 2010 Author Share Posted January 15, 2010 Oh, i get why keys don't binding, the problem in "play" gamemode, for let them bind, i must first die, and after respawn, everything will be ok Link to comment
CrazyDude69 Posted January 18, 2010 Author Share Posted January 18, 2010 hey everyone again! I have one problem, i have client-side script, i created this function: function isPedDriver( ped, vehicle ) local pedIn = GetVehicleOccupant( vehicle, 0 ) if pedIn == ped then return true else return false end end This function checks, if "ped" sitting in "vehicle" as driver (driver seat 0), if yes, returns true, if not, returns false, and yes, before i using this function, i check if player in vehicle, so when i use it, i get that in debugscript: Link to comment
CrazyDude69 Posted January 18, 2010 Author Share Posted January 18, 2010 hey everyone again! I have one problem, i have client-side script, i created this function: function isPedDriver( ped, vehicle ) local pedIn = GetVehicleOccupant( vehicle, 0 ) if pedIn == ped then return true else return false end end This function checks, if "ped" sitting in "vehicle" as driver (driver seat 0), if yes, returns true, if not, returns false, and yes, before i using this function, i check if player in vehicle, so when i use it, i get that in debugscript: Link to comment
50p Posted January 18, 2010 Share Posted January 18, 2010 Lua is case-sensitive language. GetVehicleOccupant is not the same as getVehicleOccupant. You should already know that. https://wiki.multitheftauto.com/wiki/Debugging Link to comment
50p Posted January 18, 2010 Share Posted January 18, 2010 Lua is case-sensitive language. GetVehicleOccupant is not the same as getVehicleOccupant. You should already know that. https://wiki.multitheftauto.com/wiki/Debugging Link to comment
CrazyDude69 Posted January 18, 2010 Author Share Posted January 18, 2010 Lua is case-sensitive language. GetVehicleOccupant is not the same as getVehicleOccupant.You should already know that. https://wiki.multitheftauto.com/wiki/Debugging Oh shit! Thank you very much, that was mistake Link to comment
CrazyDude69 Posted January 18, 2010 Author Share Posted January 18, 2010 Lua is case-sensitive language. GetVehicleOccupant is not the same as getVehicleOccupant.You should already know that. https://wiki.multitheftauto.com/wiki/Debugging Oh shit! Thank you very much, that was mistake Link to comment
CrazyDude69 Posted January 28, 2010 Author Share Posted January 28, 2010 Hello guys, i have a new problem... I have clientside function: function rendering() if (draw) then dxDrawImage(screenWidth/2-16,screenHeight/2-70,32,32,"data/cur.png") elem = getElementsByType("vehicle") for key,value in pairs(elem) do local veh = getPedOccupiedVehicle(player) if isElementOnScreen(value) and veh ~= value then local ex,ey,ez = getElementPosition(value) local px,py,pz = getElementPosition(player) local dis = getDistanceBetweenPoints3D(ex,ey,ez,px,py,pz) if dis < 50 and isLineOfSightClear(ex,ey,ez,px,py,pz,true,false,false,false) then local x,y = getScreenFromWorldPosition(ex,ey,ez) local hp = getElementHealth(value) if x and hp ~= 0 then hp = hp/10000 dxDrawRectangle(x-62.5, y, 125, 25, tocolor(0,0,0,100)) dxDrawRectangle(x-59.5, y+3, 119*hp, 19, tocolor(255,0,0,200)) end end end end end end addEventHandler("onClientRender", getRootElement(), rendering) and i have: function setHealthC(theVehicle) local vx, vy, vz = getElementPosition(theVehicle) local vrx, vry, vrz = getElementRotation(theVehicle) setElementHealth(theVehicle, 10000.0) military = createObject(3884, vx,vy,vz+1,vrx,vry,vrz) setObjectStatic(military, true) setElementCollisionsEnabled(military, false) attachElements(military, theVehicle) end addEventHandler("onClientPlayerVehicleEnter", getRootElement(), setHealthC) So there is a problem: When i enter car, and looking how many my car have health, it's write's that i have 10000 health, when i exit, now i can see that car HP bar, and it shows that this car has about 1000hp, so hp bar is not full, also when i'm in car, and other players looking at my car HP bar, they see that thing too, that hp bar is not full, only 1 time, it showed me full bar, but when i rejoined from car, i again see, that hp bar is not full, i think the problem in desync with client and server, but maybe no? I hope u will help me! 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