DakiLLa Posted September 1, 2008 Share Posted September 1, 2008 I have a gui window with button: ....... if ( source == HealthButton ) then triggerServerEvent ( "MaxHealth", getRootElement () ) and i need to set max health when click on button, but have two errors: addEvent ( "MaxHealth", true ) function SetMaxHealth ( thePlayer ) local money = getPlayerMoney ( thePlayer ) if (money < 2000) then outputChatBox ( "You don't have enough money!", thePlayer, 255, 0, 0 ) else setPlayerStat ( thePlayer, 24, 999 ) outputChatBox ( "Now your health set to Max!", thePlayer, 255, 255, 0 ) end end addEventHandler ( "MaxHealth", getRootElement (), SetMaxHealth ) Warning: Bad argument @ 'getPlayerMoney' - line: 5 Error: ..line6: attempt to compare a boolean with number. can anybody help? Link to comment
Ace_Gambit Posted September 1, 2008 Share Posted September 1, 2008 The server-side function is expecting a parameters that is never passed on by the client (thePlayer). This leaves you with two options: 1) You pass the parameter by specifying it client-side: triggerServerEvent ( "MaxHealth", getRootElement (), getLocalPlayer() ) Which is in terms of syntax not wrong (but in this case strongly discouraged). 2) You use the predefined variable attached to the handler function (source): function SetMaxHealth () local money = getPlayerMoney ( source ) if (money < 2000) then outputChatBox ( "You don't have enough money!", source , 255, 0, 0 ) else setPlayerStat ( source , 24, 999 ) outputChatBox ( "Now your health set to Max!", source , 255, 255, 0 ) end end Option 1 is not practical because the "player" element is already passed on. Link to comment
DakiLLa Posted September 1, 2008 Author Share Posted September 1, 2008 ok, i have fixed this but all the same errors: warning: bad 'player' pointer @ 'getPlayerMoney' (1) error: attempt to compare boolean with number EDIT: yea, it works, problem in this line: triggerServerEvent ( "MaxHealth", getRootElement (), getLocalPlayer () ) should be triggerServerEvent ( "MaxHealth", getLocalPlayer () ) thanks for help, Ace! Link to comment
DakiLLa Posted September 3, 2008 Author Share Posted September 3, 2008 how to check vehicle ID when player in vehicle hits marker ? dftVehicle = { [578]=true } function MarkerHit ( player, vehicle, seat, jacked ) local OccVehicle = getPlayerOccupiedVehicle ( player ) if ( OccVehicle ) then if ( dftVehicle[getVehicleID(vehicle)] ) and source == Marker then outputChatBox ( "Checked!" ) end end end addEventHandler ( "onMarkerHit", getRootElement (), MarkerHit ) not works only warning in 'getVehicleID. correct me. Link to comment
Ace_Gambit Posted September 3, 2008 Share Posted September 3, 2008 (edited) how to check vehicle ID when player in vehicle hits marker ? dftVehicle = { [578]=true } function MarkerHit ( player, vehicle, seat, jacked ) local OccVehicle = getPlayerOccupiedVehicle ( player ) if ( OccVehicle ) then if ( dftVehicle[getVehicleID(vehicle)] ) and source == Marker then outputChatBox ( "Checked!" ) end end end addEventHandler ( "onMarkerHit", getRootElement (), MarkerHit ) not works only warning in 'getVehicleID. correct me. You should really read the wiki more carefully. The onMarkerHit call back event does not have four parameters. In your script the vehicle parameter returns a boolean value representing the dimensional state of a player. dftVehicle = { [578]=true } function MarkerHit ( player, matchingDimension ) -- You can even skip the last parameter if you not intend using it. local OccVehicle = getPlayerOccupiedVehicle ( player ) if ( OccVehicle ) then if ( dftVehicle[getVehicleID(OccVehicle)] ) and source == Marker then outputChatBox ( "Checked!" ) end end end addEventHandler ( "onMarkerHit", getRootElement (), MarkerHit ) Edited September 3, 2008 by Guest Link to comment
Gamesnert Posted September 3, 2008 Share Posted September 3, 2008 how to check vehicle ID when player in vehicle hits marker ? dftVehicle = { [578]=true } function MarkerHit ( player, vehicle, seat, jacked ) local OccVehicle = getPlayerOccupiedVehicle ( player ) if ( OccVehicle ) then if ( dftVehicle[getVehicleID(vehicle)] ) and source == Marker then outputChatBox ( "Checked!" ) end end end addEventHandler ( "onMarkerHit", getRootElement (), MarkerHit ) not works only warning in 'getVehicleID. correct me. dftVehicle = { [578]=true } function MarkerHit ( player, vehicle, seat, jacked ) local OccVehicle = getPlayerOccupiedVehicle ( player ) if ( OccVehicle ) then if ( dftVehicle[getVehicleID(OccVehicle)] ) and source == Marker then outputChatBox ( "Checked!" ) end end end addEventHandler ( "onMarkerHit", getRootElement (), MarkerHit ) Fixed I guess 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