jkub Posted January 25, 2009 Share Posted January 25, 2009 I have created a small script that tells if a player is going over 275 mph but I cant really find any event handlers to make it function I was looking through the wiki and I saw "onClientRender" which looked to be what I was looking for because it said somthing like it is triggered every time gta renders a new frame so I thought that might be useful for this script. but When I put it in the script it does nothing. What am I doing wrong? function vehiclesBySpeed ( thePlayer, theVehicle ) local playerName = getClientName ( thePlayer ) local theVehicle = getPlayerOccupiedVehicle ( thePlayer ) local speedx, speedy, speedz = getElementVelocity ( theVehicle ) local realSpeed = ( speedx^2 + speedy^2 + speedz^2 )^( 0.5 ) if ( realSpeed > 2.75 ) then outputChatBox ( playerName.. "'s vehicle is suspicious", thePlayer, 175, 100, 50 ) else end end addEventHandler ( "onClientRender", getRootElement(), vehiclesBySpeed ) I used a sample from the wiki and Built the rest from there. Link to comment
Gamesnert Posted January 25, 2009 Share Posted January 25, 2009 Wait... Correct me if I'm wrong, but it seems like you're using a client-side event on a server-side script? Make this function client-side. If you don't know how to, the link I just gave should help you out. Note that if you use outputChatBox() client-side, only the player himself will get to see the message. If you want to make the message appear to more than 1 person, trigger an server-side event with triggerServerEvent. (see example) Link to comment
jkub Posted January 25, 2009 Author Share Posted January 25, 2009 k thx. got the onClientRender to work but I havent really got to test it yet because as i would figure it causes massive lag. is there a way to eliminate that lag. I would like fast rendering but I dont think like 40-50 renders a second is neccessary lol Link to comment
DiSaMe Posted January 25, 2009 Share Posted January 25, 2009 k thx. got the onClientRender to work but I havent really got to test it yet because as i would figure it causes massive lag. is there a way to eliminate that lag. I would like fast rendering but I dont think like 40-50 renders a second is neccessary lol Maybe it gets speed of vehicle that doesn't exist (when player is on foot)? You need to make the script check if the vehicle exists. Link to comment
Gamesnert Posted January 25, 2009 Share Posted January 25, 2009 k thx. got the onClientRender to work but I havent really got to test it yet because as i would figure it causes massive lag. is there a way to eliminate that lag. I would like fast rendering but I dont think like 40-50 renders a second is neccessary lol Maybe it gets speed of vehicle that doesn't exist (when player is on foot)? You need to make the script check if the vehicle exists. Besides that, it might be an idea to do it in an 100-500 ms timer. I don't think you need to check this about 30-50 times per second... Link to comment
50p Posted January 25, 2009 Share Posted January 25, 2009 Did you know that functions triggered by onClientRender do not have any parameters? That means you will never get speed of a car because you try to a car of "nil" value. You should enable debug window before you ask question here... I think you get lots of errors. Link to comment
Gamesnert Posted January 25, 2009 Share Posted January 25, 2009 Did you know that functions triggered by onClientRender do not have any parameters? That means you will never get speed of a car because you try to a car of "nil" value. You should enable debug window before you ask question here... I think you get lots of errors. Well, actually, he might try to get a car of thePlayer nil. He defines theVehicle later on again. (line 4) But I don't know if he changed it to getLocalPlayer(). Still though, jkub it's better if you open the debugwindow and tell us if there's an errorspam. Link to comment
jkub Posted January 27, 2009 Author Share Posted January 27, 2009 ... I would like to do a debug but now my mta is not even starting... the pop up messages "stop playing with yourself" comes up and it just sits there with the busy hourglass icon Link to comment
jkub Posted January 27, 2009 Author Share Posted January 27, 2009 k i got my mta working again I am now triggering the function throught another function... one that checks if the vehicles health is too high. i can see several problems in this myself like why I used vehicle health 999 instead of the max 1000 its for testing purposes so i can get to the speed part of the script. and another problem is that it is triggered through this function which has to be triggered by a cheating vehicle anyway. cheating i mean ( has more then 1000 health ) I think there are new trainers or sobeit thingys out there that dont use over 1000 vehicle health anymore but another way to do infinite vehicle health im not sure lol.. and another prob is that its triggers the command handler which is totaly desperate for this situation. and too add to it the executecommandhandler line only works if the loop part of it is set to "0" any other number will not work. i just lagged myself out with onclientrender now for this current version i have tested it and it outputs nothing to the debug window... function vehiclesByHealth ( thePlayer, theVehicle, seat ) local theVehicle = getPlayerOccupiedVehicle ( thePlayer ) local vehicleHealth = getElementHealth ( theVehicle ) local playerName = getClientName ( thePlayer ) local driver = getVehicleOccupant ( theVehicle, 0 ) if ( driver ) then if ( vehicleHealth > 999 ) then outputChatBox ( playerName.. "'s vehicle is suspicious", thePlayer, 175, 100, 50 ) setTimer ( executeCommandHandler, 500, 0, "speeding", thePlayer ) else end else end end addEventHandler ( "onVehicleEnter", getRootElement(), vehiclesByHealth ) function vehiclesBySpeed ( thePlayer, theVehicle ) local playerName = getClientName ( thePlayer ) local theVehicle = getPlayerOccupiedVehicle ( thePlayer ) local speedx, speedy, speedz = getElementVelocity ( theVehicle ) local realSpeed = ( speedx^2 + speedy^2 + speedz^2 )^( 0.5 ) if ( realSpeed > 2.75 ) then outputChatBox ( playerName.. "'s vehicle is suspicious", thePlayer, 175, 100, 50 ) else end end addCommandHandler ( "speeding", vehiclesBySpeed ) Link to comment
Gamesnert Posted January 27, 2009 Share Posted January 27, 2009 Wait a moment... He gets suspicious from 2.75 or higher? Isn't 1.0 almost the max speed of an Infernus? =/ Another point that might be important to note: When you're entering a vehicle, the vehicle's speed is about 0. And then you execute "/speeding" which checks for how fast it's going. Well I guess it's not going 3 times as fast as the Infernus yet while getting in... Also, "/speeding" doesn't seem to stop triggering when you get out of a vehicle. But that's not necessary in this state yet anyway 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