Multi Posted May 22, 2014 Share Posted May 22, 2014 Why not working ??? Please help ;/ Server: function wyjdz(player, seat, jacked) if getElementData(source, "komb") == true then destroyElement(source) triggerClientEvent ("koniecc", getLocalPlayer(), player) end end addEventHandler("onVehicleExit", getRootElement(), wyjdz) Client: addEvent ("koniecc", true) addEventHandler ("koniecc", root, function (thePlayer) if thePlayer == getLocalPlayer() then setElementData(thePlayer, "wyjazd", false) setElementData(thePlayer, "1-19", false) setElementData(thePlayer, "2-19", false) setElementData(thePlayer, "3-19", false) setElementData(thePlayer, "4-19", false) setElementData(thePlayer, "5-19", false) setElementData(thePlayer, "6-19", false) setElementData(thePlayer, "7-19", false) setElementData(thePlayer, "8-19", false) setElementData(thePlayer, "9-19", false) setElementData(thePlayer, "10-19", false) setElementData(thePlayer, "11-19", false) setElementData(thePlayer, "12-19", false) setElementData(thePlayer, "13-19", false) setElementData(thePlayer, "14-19", false) setElementData(thePlayer, "15-19", false) setElementData(thePlayer, "16-19", false) setElementData(thePlayer, "17-19", false) setElementData(thePlayer, "18-19", false) setElementData(thePlayer, "19-19", false) destroyElement( niewidok2 ) destroyElement( niewidok3 ) end end ) Link to comment
Deepu Posted May 22, 2014 Share Posted May 22, 2014 There are multiple errors. First, You dint define the source.. Is it thePlayer or some other element? second, You skipped the other 2 parameters.... third, you can't string a numerical value. you did "1-9" or something. and false? why false? fourth "if getElementData(source, "komb") == true then" ... why true?, it must be a value. Like 1 or 2 or 3 or .... infinity... fifth why do you want to add thePlayer as the parameter when already thePlayer is the localPlayer or if not, then why not use this? "local thePlayer = getLocalPlayer()" sixth "destroyElement( niewidok2 )" that element is neither defined nor used in the function... So, that's it.. Now you can easily fix the script.. Regards, Don (deepu) Link to comment
Multi Posted May 22, 2014 Author Share Posted May 22, 2014 triggerClientEvent ("koniecc", getLocalPlayer(), player) This only not working the Komp is the Element of Car and it working to destroy but trigger not working why? Link to comment
Deepu Posted May 22, 2014 Share Posted May 22, 2014 uhmm, friend can you explain more clearly? I dint understand you. EDIT: I GET WHAT YOU ARE TELLING LOL... Sorry.. You did an error in the first 6 lines. you used source as the element to be destroyed. (its a warning in mta debug) so you must define it like if source == getElementByType(....) then Or something like that. Or if you are using the vehicle model or used vehicle or player's vehicle then use something like this. local peddyCarry = getPedOccupiedVehicle(localPlayer) if source == peddyCarry then -- LocalPlayer since its a client sided script. But naturally, you use source for players. thats it. and Komb is not the element of car... Komb is just the key used in the element's data. And because you used source as the car's element in this context, source is the element of car.. regards, Don (deepu) Link to comment
pa3ck Posted May 22, 2014 Share Posted May 22, 2014 I don't know what Deepu is on about, but your trigger is the problem. There's no 'getLocalPlayer()' server side. You defined 'player' in the function already, just use player. Also, if you want to send it to one player only, use the player element as the 'sendTo' argument when triggering. function wyjdz(player, seat, jacked) if getElementData(source, "komb") == true then destroyElement(source) triggerClientEvent (player, "koniecc", player ) end end addEventHandler("onVehicleExit", getRootElement(), wyjdz) Also, if 'sendTo' is a player, you can use source client side, you don't need to pass the player variable. Link to comment
Multi Posted May 22, 2014 Author Share Posted May 22, 2014 Yes i mean only the Trigger not working, and i don't know why can someone help me?? triggerClientEvent (player, "koniecc", player ) -- not working Link to comment
pa3ck Posted May 22, 2014 Share Posted May 22, 2014 Show me your client side script, using [ code = lua ] [ / code ] without spaces. Link to comment
Moderators Citizen Posted May 23, 2014 Moderators Share Posted May 23, 2014 triggerClientEvent (player, "koniecc", player ) -- not working If your meta is ok, then the trigger is working, it's not because the 2 elements you are trying to destroy aren't destroyed than the trigger is obviously not working. server function wyjdz(player, seat, jacked) if getElementData(source, "komb") == true then outputChatBox("Vehicle is a 'komb'") -- debugging destroyElement(source) triggerClientEvent(player, "koniecc", player) else outputChatBox("Vehicle is not a 'komb'") -- debugging end end addEventHandler("onVehicleExit", root wyjdz) client: addEvent ("koniecc", true) addEventHandler ("koniecc", root, function () setElementData(localPlayer, "wyjazd", false) setElementData(localPlayer, "1-19", false) setElementData(localPlayer, "2-19", false) setElementData(localPlayer, "3-19", false) setElementData(localPlayer, "4-19", false) setElementData(localPlayer, "5-19", false) setElementData(localPlayer, "6-19", false) setElementData(localPlayer, "7-19", false) setElementData(localPlayer, "8-19", false) setElementData(localPlayer, "9-19", false) setElementData(localPlayer, "10-19", false) setElementData(localPlayer, "11-19", false) setElementData(localPlayer, "12-19", false) setElementData(localPlayer, "13-19", false) setElementData(localPlayer, "14-19", false) setElementData(localPlayer, "15-19", false) setElementData(localPlayer, "16-19", false) setElementData(localPlayer, "17-19", false) setElementData(localPlayer, "18-19", false) setElementData(localPlayer, "19-19", false) if not destroyElement( niewidok2 ) then outputChatBox("Failed to destroy 'niewidok2'") -- debugging else outputChatBox("Successfully destroyed 'niewidok2'") -- debugging end if not destroyElement( niewidok3 ) then outputChatBox("Failed to destroy 'niewidok3'") -- debugging else outputChatBox("Successfully destroyed 'niewidok2'") -- debugging end end) Also loops are your friends ! client: addEvent ("koniecc", true) addEventHandler ("koniecc", root, function () setElementData(localPlayer, "wyjazd", false) for k = 1, 19 do setElementData(localPlayer, k.."-19", false) end if not destroyElement( niewidok2 ) then outputChatBox("Failed to destroy 'niewidok2'") -- debugging else outputChatBox("Successfully destroyed 'niewidok2'") -- debugging end if not destroyElement( niewidok3 ) then outputChatBox("Failed to destroy 'niewidok3'") -- debugging else outputChatBox("Successfully destroyed 'niewidok2'") -- debugging end end) using [ code = lua ] [ / code ] without spaces. What about [ lua] [/lua] ? (without spaces ofc) Link to comment
Deepu Posted May 28, 2014 Share Posted May 28, 2014 yeah, Citizen is right, plus, Citizen he is using false value for setElementData and using numerics in strings. And he has confused the parameters of the source and wjdsd so is my code okay Citizen? 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