damien111 Posted August 9, 2012 Posted August 9, 2012 I am a few days into scripting! I need help with this, i know its simple but im not sure why this isnt working. it doesnt even spawn a marker. heres the code. i only have a client side file. local VehMarker createMarker (2158, 2449, 11, "Cylinder", 2, 0, 0, 255, 153) function spawnveh(hitElement, matchingDimension) pteam = getPlayerTeam (source) if pteam = "Police" then local elementType = getElementType( hitElement) local x, y, z = getElementPosition(thePlayer) local vehicle = createVehicle(tonumber(597), x, y, z) end end addEventHandler ( "onMarkerHit", VehMarker, spawnveh )
Castillo Posted August 9, 2012 Posted August 9, 2012 It has many errors. local VehMarker createMarker ( 2158, 2449, 11, "cylinder", 2, 0, 0, 255, 153 ) function spawnveh ( hitElement, matchingDimension ) local elementType = getElementType ( hitElement ) if ( elementType == "player" ) then local pteam = getPlayerTeam ( hitElement ) local pTeamName = ( pteam and getTeamName ( pteam ) or "" ) if ( pTeamName = "Police" ) then local x, y, z = getElementPosition ( hitElement ) local vehicle = createVehicle ( 597, x, y, z ) end end end addEventHandler ( "onMarkerHit", VehMarker, spawnveh ) That should work.
damien111 Posted August 9, 2012 Author Posted August 9, 2012 (edited) Thanks so much. & i did that from scratch, that's why it had so many errors Edited August 9, 2012 by Guest
Castillo Posted August 9, 2012 Posted August 9, 2012 You're welcome. P.S: We all learn from trial & error.
damien111 Posted August 9, 2012 Author Posted August 9, 2012 I have been and will keep depending on this forum and be posting a lot. Hope that you can help again cause your server is so amazing!!
TAPL Posted August 9, 2012 Posted August 9, 2012 line 8 if ( pTeamName = "Police" ) then should be if ( pTeamName == "Police" ) then
damien111 Posted August 9, 2012 Author Posted August 9, 2012 what would that have to do with the marker being created
TAPL Posted August 9, 2012 Posted August 9, 2012 lol this local VehMarker createMarker ( 2158, 2449, 11, "cylinder", 2, 0, 0, 255, 153 ) should be local VehMarker = createMarker ( 2158, 2449, 11, "cylinder", 2, 0, 0, 255, 153 )
Anderl Posted August 9, 2012 Posted August 9, 2012 And: if ( elementType ) then Should be: if ( elementType == "player" ) then
damien111 Posted August 9, 2012 Author Posted August 9, 2012 i fixed up the code but still no marker is being created: local VehMarker = createMarker ( 2158, 2449, 11, "cylinder", 2, 0, 0, 255, 153 ) function spawnveh ( hitElement, matchingDimension ) local elementType = getElementType ( hitElement ) if ( elementType == "player" ) then local pteam = getPlayerTeam ( hitElement ) local pTeamName = ( pteam and getTeamName ( pteam ) or "" ) if ( pTeamName = "Police" ) then local x, y, z = getElementPosition ( hitElement ) local vehicle = createVehicle ( 597, x, y, z ) end end end addEventHandler ( "onMarkerHit", VehMarker, spawnveh )
TAPL Posted August 9, 2012 Posted August 9, 2012 i fixed up the code but still no marker is being created: local VehMarker = createMarker ( 2158, 2449, 11, "cylinder", 2, 0, 0, 255, 153 ) function spawnveh ( hitElement, matchingDimension ) local elementType = getElementType ( hitElement ) if ( elementType == "player" ) then local pteam = getPlayerTeam ( hitElement ) local pTeamName = ( pteam and getTeamName ( pteam ) or "" ) if ( pTeamName = "Police" ) then local x, y, z = getElementPosition ( hitElement ) local vehicle = createVehicle ( 597, x, y, z ) end end end addEventHandler ( "onMarkerHit", VehMarker, spawnveh ) You didn't fix this one line 8 if ( pTeamName = "Police" ) then should be if ( pTeamName == "Police" ) then
TAPL Posted August 9, 2012 Posted August 9, 2012 Agh! Still, no marker. huh? i test it and working. show your meta.xml
Castillo Posted August 9, 2012 Posted August 9, 2012 And: if ( elementType ) then Should be: if ( elementType == "player" ) then Oh, my bad, I forgot about that part.
damien111 Posted August 9, 2012 Author Posted August 9, 2012 so has anyone figured out what the prob was? i need to know why it isnt making the marker ill try making it serverside
Anderl Posted August 9, 2012 Posted August 9, 2012 so has anyone figured out what the prob was? i need to know why it isnt making the marker ill try making it serverside The code is server-side as I said, but you added it as client in the meta.xml
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