Jump to content

[solved] Bad player ' pointer @ 'toggleControl'(1)..


Sora

Recommended Posts

hi , i created my own taxi mission script and this error is really anonnying me

0e3e424d6cfa00.png

i got this error , and my code is all right , idk where is the wrong :S

this code gonna be started when the player hits the marker

function finish(player) 
local amount = math.random(200,800) 
if getElementData(player,"TaxiDriver1") == true then 
givePlayerMoney ( player, amount ) 
outputChatBox("* Congratulations : you got #00ff00$"..amount.."#ffffff !",player,255,255,255,true) 
outputChatBox("* if you want to leave taxi mission type /leavetaxi",player,255,255,255,true) 
triggerClientEvent(player,"finished",player) 
       destroyElement(finishblip) 
        destroyElement(finishM) 
        setElementData(player,"TaxiRequester",false) 
setElementData(player,"TaxiDriver1",false) 
toggleControl ( player, "enter_exit", true ) 
toggleControl ( player, "enter_passenger", true ) 
setControlState ( player, "handbrake", true ) 
setControlState ( player, "handbrake", false ) 
else 
setElementData(player,"TaxiRequester",false) 
toggleControl ( player, "enter_passenger", true ) 
toggleControl ( player, "enter_exit", true ) 
setControlState ( player, "enter_exit", true ) 
if isControlEnabled ( player, "enter_exit" ) == false then 
toggleControl ( player, "enter_exit", true ) 
setControlState ( player, "enter_exit", true ) 
end 
end 
end 

Edited by Guest
Link to comment
function finish(player) 
local amount = math.random(200,800) 
if getElementType(player) == "player" then 
if getElementData(player,"TaxiDriver1") == true then 
givePlayerMoney ( player, amount ) 
outputChatBox("* Congratulations : you got #00ff00$"..amount.."#ffffff !",player,255,255,255,true) 
outputChatBox("* if you want to leave taxi mission type /leavetaxi",player,255,255,255,true) 
triggerClientEvent(player,"finished",player) 
       destroyElement(finishblip) 
        destroyElement(finishM) 
        setElementData(player,"TaxiRequester",false) 
setElementData(player,"TaxiDriver1",false) 
toggleControl ( player, "enter_exit", true ) 
toggleControl ( player, "enter_passenger", true ) 
setControlState ( player, "handbrake", true ) 
setControlState ( player, "handbrake", false ) 
end 
elseif getElementData(player,"TaxiDriver1") == false then 
setElementData(player,"TaxiRequester",false) 
toggleControl ( player, "enter_exit", true ) -- this is error bad pointer 
toggleControl ( player, "enter_passenger", true ) -- and this 
setControlState ( player, "enter_exit", true ) -- and this  
end 
end 
  

what's wrong ? it's says again bad pointer .. , and the old code with getElementByType is do nothing

i just wants the script to enable enter_exit and enter_passenger then force enter for the player

Link to comment

here where marker created , and where event added

addEvent("cb",true) 
addEventHandler("cb",getRootElement(), 
function (x,y,z) 
  
    finishblip = createBlip ( x, y, z, 42, 0, 0, 0, 255, 255,1, 99999) 
    finishM = createMarker (x,y,z, "checkpoint", 3, 255, 255, 0, 170) 
    setElementVisibleTo ( finishblip, getRootElement ( ), false ) 
    setElementVisibleTo ( finishM, getRootElement ( ), false ) 
  
    addEventHandler("onMarkerHit", finishM,finish) 
  
end) 

this code below blocking the keys enter and g , to make the taxi requester and the driver can't get out

it's works fine but just blocking enter , and g still works

now it's not the problem , the problem is when the taxi driving to the finish marker

the requester should resore his access to enter and should get out from the car ( because i added setControlState , that forcing enter )

and also it's makes the fmarker and the fblip seen by the person who had hit the marker

function start(vehicle, matchingDimension) 
    if getElementType(vehicle) ~= "vehicle" then return end 
     player = getElementData(source,"Requester") 
    if not player then return end 
     player = getPlayerFromName(player)  
    if not player then return end 
     controller = getVehicleController(vehicle) 
    if getElementData(controller,"Taxi") == true then 
        setElementData(controller,"TaxiDriver1",true) 
        outputChatBox("* you have successfully got this mission",controller,255,255,0,true) 
        destroyElement(tMarkers[player]) 
        destroyElement(tBlips[player]) 
        tMarkers[player] = nil 
        tBlips[player]= nil 
        outputChatBox("* Mission :  follow the 'T' blip in the Minimap",controller,255,255,0,true) 
        outputChatBox("* Mission :  you should finish before the time over.",controller,255,255,0,true) 
        setElementVisibleTo ( finishblip, controller, true ) 
        setElementVisibleTo ( finishM, controller, true ) 
        warpPedIntoVehicle ( player, vehicle,2) 
        triggerClientEvent(controller,"startTimer",controller,player,finishblip,finishM) 
        toggleControl ( player, "enter_exit", false ) 
        toggleControl ( player, "enter_passenger", false ) 
        setElementData(player,"TaxiRequester",false) 
        toggleControl ( controller, "enter_exit", false ) 
        toggleControl ( controller, "enter_passenger", false ) 
  
    end 
end 

Link to comment

did this worked? :

    
     toggleControl ( controller, "enter_exit", false ) 
        toggleControl ( controller, "enter_passenger", false ) 

Because here are you using player and above the controller

        toggleControl ( player, "enter_exit", false ) 
        toggleControl ( player, "enter_passenger", false ) 
        setElementData(player,"TaxiRequester",false) 

Link to comment
did this worked? :
    
     toggleControl ( controller, "enter_exit", false ) 
        toggleControl ( controller, "enter_passenger", false ) 

Because here are you using player and above the controller

        toggleControl ( player, "enter_exit", false ) 
        toggleControl ( player, "enter_passenger", false ) 
        setElementData(player,"TaxiRequester",false) 

hey thank you for reply , yep this works fine the problem is here

function finish(player) 
local amount = math.random(200,800) 
if getElementType(player) == "player" then 
if getElementData(player,"TaxiDriver1") == true then 
givePlayerMoney ( player, amount ) 
outputChatBox("* Congratulations : you got #00ff00$"..amount.."#ffffff !",player,255,255,255,true) 
outputChatBox("* if you want to leave taxi mission type /leavetaxi",player,255,255,255,true) 
triggerClientEvent(player,"finished",player) 
       destroyElement(finishblip) 
        destroyElement(finishM) 
        setElementData(player,"TaxiRequester",false) 
setElementData(player,"TaxiDriver1",false) 
toggleControl ( player, "enter_exit", true ) 
toggleControl ( player, "enter_passenger", true ) 
setControlState ( player, "handbrake", true ) 
setControlState ( player, "handbrake", false ) 
end 
elseif getElementData(player,"TaxiDriver1") == false then 
setElementData(player,"TaxiRequester",false) 
toggleControl ( player, "enter_exit", true ) -- this is error bad pointer 
toggleControl ( player, "enter_passenger", true ) -- and this 
setControlState ( player, "enter_exit", true ) -- and this 
end 
end 

they should enable the enter for the requester or the passenger then force him to press enter

but they won't work

Link to comment
  • Other Languages Moderators

Try

function finish(player) 
     local amount = math.random(200,800) 
     if getElementType(player) == "player" then 
          if getElementData(player,"TaxiDriver1") then 
               givePlayerMoney(player, amount) 
               outputChatBox("* Congratulations : you got #00ff00$"..amount.."#ffffff !",player,255,255,255,true) 
               outputChatBox("* if you want to leave taxi mission type /leavetaxi",player,255,255,255,true) 
               triggerClientEvent(player,"finished",player) 
               destroyElement(finishblip) 
               destroyElement(finishM) 
               setElementData(player,"TaxiRequester",false) 
               setElementData(player,"TaxiDriver1",false) 
               toggleControl(player, "enter_exit", true) 
               toggleControl(player, "enter_passenger", true) 
               setControlState(player, "handbrake", true) 
               setControlState(player, "handbrake", false) 
          elseif not getElementData(player,"TaxiDriver1") then 
               setElementData(player,"TaxiRequester",false) 
               toggleControl(player, "enter_exit", true) -- this is error bad pointer 
               toggleControl(player, "enter_passenger", true) -- and this 
               setControlState(player, "enter_exit", true) -- and this 
          end 
     end 
end 

Link to comment
  • Other Languages Moderators
thank you , pointor gone but still same not enabling enter and not force enter

You want it enter if the element data "TaxiDriver1" is true or false?

i guess your problem is from the element data, you have to adjust it.

Link to comment
  • Other Languages Moderators
nope my problem is just from the toggleControl and the setControlState

they not works -.-

ehh

Could you explain what should happen if the element data was true, and what should happen if the element data was false?

i can't get what you trying to do.

Link to comment

i used the element data to differentiate between the taxi driver and the requester(passenger)

because i want the taxi driver to get his controls back and get a money (this works fine)

and the requester(passenger) to get his controls back and get out from the car (this not work)

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...