gghvcffcv Posted March 15, 2014 Posted March 15, 2014 Hey guys, i have been with this error i cannot progress due to it, the problem is When a player hits Any marker in the Server the Script gives the skin of SWAT and i want that it be in the marker that i put in the table i don't know why it doesn't works. Server: markersB = { {1287.91064, -1643.70593, 12.54688}, } pedA = { {1287.91064, -1643.70593, 13.54688}, } for i,v in ipairs (pedA) do SWAT = createPed (285, v[1], v[2], v[3], 270) end for k,swat in ipairs (markersB) do createMarker(swat[1], swat[2], swat[3], "cylinder", 0.9, 0, 0, 255, 255) createBlip (swat[1], swat[2], swat[3], 58, 2, 255, 0, 0, 255) end function aceptarr () policeteam = createTeam ("SWAT", 0, 0, 170) setPlayerTeam ( source, policeteam ) setPlayerNametagColor ( source, 0, 0, 170 ) giveWeapon (source, 23, 230) giveWeapon (source, 3) giveWeapon (source, 41, 5500) setElementModel (source, 285) end addEvent( "onGreeting", true ) addEventHandler( "onGreeting", root, aceptarr ) function rechazarr () outputChatBox ("You haven't Accepted The Police Job", source, 231, 0, 0) end addEvent( "onGreetinA", true ) addEventHandler( "onGreetinA", root, rechazarr ) Client: addEventHandler("onClientMarkerHit", resourceRoot, function(hitElement) if ( hitElement == localPlayer ) then panel = guiCreateWindow(485, 160, 375, 320, "SARS:RPG Police", false) guiWindowSetSizable(panel, false) memo = guiCreateMemo(9, 24, 356, 220, "Welcome to the police Job of SARS:RPG, if you accept this Job you will be given ( Nightstick, Spray, Silenced ), With this Job you can arrest Wanted people, To arrest People Use you Silenced Pistol and get Them.", false, panel) guiMemoSetReadOnly(memo, true) aceptar = guiCreateButton(9, 252, 174, 60, "Accept", false, panel) guiSetFont(aceptar, "sa-header") rechazar = guiCreateButton(191, 252, 174, 60, "Close ", false, panel) guiSetFont(rechazar, "sa-header") showCursor (true) addEventHandler ("onClientGUIClick", aceptar, aceptarr, false) addEventHandler ("onClientGUIClick", rechazar, rechazarr, false) end end ) function aceptarr (hitElement) showCursor (false) guiSetVisible (panel, false) triggerServerEvent ( "onGreeting", localPlayer ) end function rechazarr (hitElement) showCursor (false) guiSetVisible (panel, false) triggerServerEvent ( "onGreetinA", localPlayer ) end
Castillo Posted March 16, 2014 Posted March 16, 2014 You can either create the markers client side, or you can set a element data value to the markers, and then you can check client side if the marker the player hit has that element data.
gghvcffcv Posted March 16, 2014 Author Posted March 16, 2014 You can either create the markers client side, or you can set a element data value to the markers, and then you can check client side if the marker the player hit has that element data. Sorry i don't understand
Castillo Posted March 16, 2014 Posted March 16, 2014 -- server side: for k,swat in ipairs (markersB) do local marker = createMarker(swat[1], swat[2], swat[3], "cylinder", 0.9, 0, 0, 255, 255) setElementData ( marker, "isSWATMarker", true ) createBlip (swat[1], swat[2], swat[3], 58, 2, 255, 0, 0, 255) end -- client side: addEventHandler ( "onClientMarkerHit", resourceRoot, function ( hitElement ) if ( hitElement == localPlayer ) then if ( not getElementData ( source, "isSWATMarker" ) ) then return end
pa3ck Posted March 16, 2014 Posted March 16, 2014 Because you will need to specify which markers should the player hit eg: -- Client addEventHandler("onClientMarkerHit", myMarker, myFunction ) OR --Server addEventHandler("onMarkerHit", myMarker, myFunction ) Also, you either make the markers and event server side then trigger a client event to open up your GUI or make everything client side and trigger a server event for setting the player team and giving the player weapon. EDIT: Ops, didn't see Solid's post, sorry.
gghvcffcv Posted March 16, 2014 Author Posted March 16, 2014 --Client addEventHandler ( "onClientMarkerHit", resourceRoot, function ( hitElement ) if ( hitElement == localPlayer ) then if ( not getElementData ( source, "isSWATMarker" ) ) then return memo = guiCreateMemo(9, 24, 356, 220, "Welcome to the SWAT Job of SARS:RPG, if you accept this Job you will be given ( Nightstick, Spray, Silenced, M4, MP5, Sniper, Parachute ), With this Job you can arrest Wanted people, To arrest People Use you Silenced Pistol and get Them.", false, panel) guiMemoSetReadOnly(memo, true) aceptar = guiCreateButton(9, 252, 174, 60, "Accept", false, panel) guiSetFont(aceptar, "sa-header") rechazar = guiCreateButton(191, 252, 174, 60, "Close ", false, panel) guiSetFont(rechazar, "sa-header") showCursor (true) addEventHandler ("onClientGUIClick", aceptar, aceptarr, false) addEventHandler ("onClientGUIClick", rechazar, rechazarr, false) end end end ) function aceptarr (hitElement) showCursor (false) guiSetVisible (panel, false) triggerServerEvent ( "onGreeting", localPlayer ) end function rechazarr (hitElement) showCursor (false) guiSetVisible (panel, false) triggerServerEvent ( "onGreetinA", localPlayer ) end --Server markersB = { {1287.91064, -1643.70593, 12.54688}, } pedA = { {1287.91064, -1643.70593, 13.54688}, } for i,v in ipairs (pedA) do SWAT = createPed (285, v[1], v[2], v[3], 270) end for k,swat in ipairs (markersB) do local marker = createMarker(swat[1], swat[2], swat[3], "cylinder", 0.9, 0, 0, 255, 255) setElementData ( marker, "isSWATMarker", true ) createBlip (swat[1], swat[2], swat[3], 58, 2, 255, 0, 0, 255) end function aceptarr () policeteam = createTeam ("SWAT", 0, 0, 170) setPlayerTeam ( source, policeteam ) setPlayerNametagColor ( source, 0, 0, 170 ) giveWeapon (source, 23, 230) giveWeapon (source, 3) giveWeapon (source, 41, 5500) setElementModel (source, 285) end addEvent( "onGreeting", true ) addEventHandler( "onGreeting", root, aceptarr ) function rechazarr () outputChatBox ("You haven't Accepted The Police Job", source, 231, 0, 0) end addEvent( "onGreetinA", true ) addEventHandler( "onGreetinA", root, rechazarr ) Not working
Castillo Posted March 16, 2014 Posted March 16, 2014 You didn't copy the end to close the 'if' statement. addEventHandler ( "onClientMarkerHit", resourceRoot, function ( hitElement ) if ( hitElement == localPlayer ) then if ( not getElementData ( source, "isSWATMarker" ) ) then return end -- This
gghvcffcv Posted March 16, 2014 Author Posted March 16, 2014 You didn't copy the end to close the 'if' statement. addEventHandler ( "onClientMarkerHit", resourceRoot, function ( hitElement ) if ( hitElement == localPlayer ) then if ( not getElementData ( source, "isSWATMarker" ) ) then return end -- This The Problem keeps Still doing everything like you told me, the problems is when i start Swat resource and i go to a police marker it gives me SWAT Skin if i go to SWAT Marker and i start police It gives me police skin
Saml1er Posted March 16, 2014 Posted March 16, 2014 Strange, the code seems fine to me. e.e addEventHandler ( "onClientMarkerHit", resourceRoot, function ( hitElement ) if hitElement == localPlayer and getElementType (source) == "marker" then outputChatBox ("Well it works ^^", getRootElement()) if ( not getElementData ( source, "isSWATMarker" ) ) then return end end -- < -- < -- remove this if the script doesn't work.
Anubhav Posted March 16, 2014 Posted March 16, 2014 Hmm realy? 3 ends needed. addEventHandler ( "onClientMarkerHit", resourceRoot, function ( hitElement ) if hitElement == localPlayer and getElementType (source) == "marker" then outputChatBox ("Well it works ^^", getRootElement()) if ( not getElementData ( source, "isSWATMarker" ) ) then return end end end) 2 for if 1 for function and another for closing the addEventHandler also needs )
Saml1er Posted March 16, 2014 Posted March 16, 2014 Hmm realy?3 ends needed. addEventHandler ( "onClientMarkerHit", resourceRoot, function ( hitElement ) if hitElement == localPlayer and getElementType (source) == "marker" then outputChatBox ("Well it works ^^", getRootElement()) if ( not getElementData ( source, "isSWATMarker" ) ) then return end end end) 2 for if 1 for function and another for closing the addEventHandler also needs ) SolidSnake just posted a check and I already know that it was just the first 5-6 lines. The script didn't work for him because he placed "end" statement at wrong place. Also there shouldn't be more than 2 ends because if there already exists and "if" statement and when you use "if not" then you don't need to add more ends.
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