UnG//Macaus Posted October 8, 2014 Share Posted October 8, 2014 Can anyone help me solve this error? everything works, but I got errors in debugscript Debugscript: WARNING: Bad argument @ 'getPlayerTeam' [Expected player at argument 1, got vehicle] Server side Zona = createMarker(1540.8887939453, -1630.9000244141, 12, "cylinder", 20, 255, 255, 255, 0) function Funcion (source) if isElementWithinMarker(source, Zona) then playerTeam = getPlayerTeam ( source ) Clann = getTeamFromName ( "Police" ) if ( playerTeam ) == Clann then veh = getPedOccupiedVehicle(source) if (veh) then moveObject ( objeto, 3000, 1541.0999755859, -1627.6999511719, 9.4 ) else moveObject ( objeto, 3000, 1541.0999755859, -1627.6999511719, 9.4 ) end end end end addEventHandler ( "onMarkerHit", Zona, Funcion ) Link to comment
n3wage Posted October 8, 2014 Share Posted October 8, 2014 Zona = createMarker(1540.8887939453, -1630.9000244141, 12, "cylinder", 20, 255, 255, 255, 0) function Funcion (player) if isElementWithinMarker(player, Zona) then playerTeam = getPlayerTeam ( player) Clann = getTeamFromName ( "Police" ) if ( playerTeam ) == Clann then veh = getPedOccupiedVehicle(player) if (veh) then moveObject ( objeto, 3000, 1541.0999755859, -1627.6999511719, 9.4 ) else moveObject ( objeto, 3000, 1541.0999755859, -1627.6999511719, 9.4 ) end end end end addEventHandler ( "onMarkerHit", Zona, Funcion ) Link to comment
UnG//Macaus Posted October 8, 2014 Author Share Posted October 8, 2014 Zona = createMarker(1540.8887939453, -1630.9000244141, 12, "cylinder", 20, 255, 255, 255, 0) function Funcion (player) if isElementWithinMarker(player, Zona) then playerTeam = getPlayerTeam ( player) Clann = getTeamFromName ( "Police" ) if ( playerTeam ) == Clann then veh = getPedOccupiedVehicle(player) if (veh) then moveObject ( objeto, 3000, 1541.0999755859, -1627.6999511719, 9.4 ) else moveObject ( objeto, 3000, 1541.0999755859, -1627.6999511719, 9.4 ) end end end end addEventHandler ( "onMarkerHit", Zona, Funcion ) Bad argument @ 'getPlayerTeam' [Expected player at argument 1, got vehicle] Bad argument @'getPedOccupiedVehicle'[Expected ped at argument 1, got vehicle] Link to comment
Mr_Moose Posted October 8, 2014 Share Posted October 8, 2014 You must handle the case when a vehicle hit's the marker, your first script would only work for player elements. This should solve your problem. Zona = createMarker(1540.8887939453, -1630.9000244141, 12, "cylinder", 20, 255, 255, 255, 0) function Funcion (source) if isElementWithinMarker(source, Zona) then local playerTeam = nil if getElementType(source) == "Player" then playerTeam = getPlayerTeam ( source ) elseif getElementType(source) == "Vehicle" then local occupant = getVehicleOccupants(source)[0] playerTeam = getPlayerTeam ( occupant ) end Clann = getTeamFromName ( "Police" ) if ( playerTeam ) == Clann then veh = getPedOccupiedVehicle(source) if (veh) then moveObject ( objeto, 3000, 1541.0999755859, -1627.6999511719, 9.4 ) else moveObject ( objeto, 3000, 1541.0999755859, -1627.6999511719, 9.4 ) end end end end addEventHandler ( "onMarkerHit", Zona, Funcion ) Link to comment
UnG//Macaus Posted October 8, 2014 Author Share Posted October 8, 2014 Does not work without errors in debugscript Link to comment
Mr_Moose Posted October 8, 2014 Share Posted October 8, 2014 Does not work without errors in debugscript What errors did you get this time? Link to comment
UnG//Macaus Posted October 8, 2014 Author Share Posted October 8, 2014 What errors did you get this time? I have no error in debugscript, and when I go up to the marker does not open the gate Link to comment
King12 Posted October 8, 2014 Share Posted October 8, 2014 Zona = createMarker(1540.8887939453, -1630.9000244141, 12, "cylinder", 20, 255, 255, 255, 0) function Funcion (hitElement) playerTeam = getPlayerTeam (hitElement) Clann = getTeamFromName ( "Police" ) if ( playerTeam ) == Clann then veh = getPedOccupiedVehicle(hitElement) if (veh) then moveObject ( objeto, 3000, 1541.0999755859, -1627.6999511719, 9.4 ) else moveObject ( objeto, 3000, 1541.0999755859, -1627.6999511719, 9.4 ) end end end addEventHandler ( "onMarkerHit", Zona, Funcion ) Link to comment
UnG//Macaus Posted October 8, 2014 Author Share Posted October 8, 2014 Zona = createMarker(1540.8887939453, -1630.9000244141, 12, "cylinder", 20, 255, 255, 255, 0) function Funcion (hitElement) playerTeam = getPlayerTeam (hitElement) Clann = getTeamFromName ( "Police" ) if ( playerTeam ) == Clann then veh = getPedOccupiedVehicle(hitElement) if (veh) then moveObject ( objeto, 3000, 1541.0999755859, -1627.6999511719, 9.4 ) else moveObject ( objeto, 3000, 1541.0999755859, -1627.6999511719, 9.4 ) end end end addEventHandler ( "onMarkerHit", Zona, Funcion ) Now besides having the same errors, the gate apre for others who are not in the Police team Link to comment
xeon17 Posted October 8, 2014 Share Posted October 8, 2014 moving = false closed = true movetime = 968 function openGate(player) if getElementType(player) == "player" then if getPlayerTeam(player) ~= getTeamFromName("Police") then return end if not moving and closed then moveObject(objecto,3000, 1541.0999755859, -1627.6999511719, 9.4) moving = true closed = false setTimer(function() moving = false end, movetime, 1) end end end addEventHandler("onMarkerHit", Zona, openGate) function closeGate(player) if getElementType(player) == "player" then if getPlayerTeam(player) ~= getTeamFromName("Police") then return end if not moving and not closed then moveObject(objecto,1540.8887939453, -1630.9000244141, 12,) moving = true closed = true setTimer(function() moving = false end, movetime, 1) end end end addEventHandler("onMarkerLeave", Zona, closeGate) Link to comment
UnG//Macaus Posted October 8, 2014 Author Share Posted October 8, 2014 moving = false closed = true movetime = 968 function openGate(player) if getElementType(player) == "player" then if getPlayerTeam(player) ~= getTeamFromName("Police") then return end if not moving and closed then moveObject(objecto,3000, 1541.0999755859, -1627.6999511719, 9.4) moving = true closed = false setTimer(function() moving = false end, movetime, 1) end end end addEventHandler("onMarkerHit", Zona, openGate) function closeGate(player) if getElementType(player) == "player" then if getPlayerTeam(player) ~= getTeamFromName("Police") then return end if not moving and not closed then moveObject(objecto,1540.8887939453, -1630.9000244141, 12,) moving = true closed = true setTimer(function() moving = false end, movetime, 1) end end end addEventHandler("onMarkerLeave", Zona, closeGate) moving = false closed = true movetime = 968 function openGate(player) if getElementType(player) == "player" then if getPlayerTeam(player) ~= getTeamFromName("Police") then return end if not moving and closed then moveObject(objeto,3000, 1541.0999755859, -1627.6999511719, 9.4) moving = true closed = false setTimer(function() moving = false end, movetime, 1) end end end addEventHandler("onMarkerHit", Zona, openGate) function closeGate(player) if getElementType(player) == "player" then if getPlayerTeam(player) ~= getTeamFromName("Police") then return end if not moving and not closed then moveObject(objeto, 3000, 1541.0999755859, -1627.6999511719, 15.199999809265) moving = true closed = true setTimer(function() moving = false end, movetime, 1) end end end addEventHandler("onMarkerLeave", Zona, closeGate) Works fine, thank XeoN- 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