X-Flow Posted February 13, 2012 Posted February 13, 2012 pls help me i am new to scripting and i made this script. its loaded and running but it doesnt react when i type /test. function Chopper ( command ) local player = getLocalPlayer local Account = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then local Px, Py, Pz = getElementPosition ( player ) local Rx, Ry, Rz = getElementRotation ( player ) local vehicle = getPedOccupiedVehicle ( player ) destroyElement ( vehicle ) local vehicle2 = createVehicle ( 497, Px, Py, Pz, Rx, Ry, Rz ) warpPedIntoVehicle ( player, vehicle2 ) else outputChatBox ( "You can not execute this command!", player ) end addCommandHandler ( "test", Chopper )
Kenix Posted February 13, 2012 Posted February 13, 2012 (edited) Server side. local uTimers = { } function Chopper ( player ) local Account = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..Account, aclGetGroup ( "Admin" ) ) then local Px, Py, Pz = getElementPosition ( player ) local Rx, Ry, Rz = getElementRotation ( player ) if isPedInVehicle( player ) then local vehicle = getPedOccupiedVehicle ( player ) destroyElement ( vehicle ) end local vehicle2 = createVehicle ( 497, Px, Py, Pz, Rx, Ry, Rz ) if isTimer( uTimers[ player ] ) then killTimer( uTimers[ player ] ) end uTimers[ player ] = setTimer( function( player,vehicle ) warpPedIntoVehicle ( player, vehicle ) end, 100, 1,player,vehicle2 ) else outputChatBox ( "You can not execute this command!", player ) end end addCommandHandler ( "test", Chopper ) addEventHandler( 'onPlayerQuit',root, function( ) uTimers[ source ] = nil end ) Updated again. You can't use function getLocalPlayer in server side. Edited February 13, 2012 by Guest
Twisted Posted February 13, 2012 Posted February 13, 2012 Kenix forgot one thing change this if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then into if isObjectInACLGroup ("user."..Account, aclGetGroup ( "Admin" ) ) then
X-Flow Posted February 13, 2012 Author Posted February 13, 2012 thank you so much, but what is uTimers?
Castillo Posted February 13, 2012 Posted February 13, 2012 "uTimers" is a table which is used to store player timers.
Kenix Posted February 13, 2012 Posted February 13, 2012 Ah yes,my bad local uTimers = { } function Chopper ( player ) local Account = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..Account, aclGetGroup ( "Admin" ) ) then local Px, Py, Pz = getElementPosition ( player ) local Rx, Ry, Rz = getElementRotation ( player ) if isPedInVehicle( player ) then local vehicle = getPedOccupiedVehicle ( player ) destroyElement ( vehicle ) end local vehicle2 = createVehicle ( 497, Px, Py, Pz, Rx, Ry, Rz ) if isTimer( uTimers[ player ] ) then killTimer( uTimers[ player ] ) end uTimers[ player ] = setTimer( function( player,vehicle ) warpPedIntoVehicle ( player, vehicle ) end, 100, 1,player,vehicle2 ) else outputChatBox ( "You can not execute this command!", player ) end end addCommandHandler ( "test", Chopper ) addEventHandler( 'onPlayerQuit',root, function( ) uTimers[ source ] = nil end ) thank you so much, but what is uTimers? uTimers is table stored timers. As an index, we use the userdata Player. If player quit remove index from table. It is very convenient we can remove the timer current ( which we need ) player and not a all players.
X-Flow Posted February 13, 2012 Author Posted February 13, 2012 I see no difference between these two scripts you posted, but i still cant seem to get a police maverick when i type /test in the chatbox.
Kenix Posted February 13, 2012 Posted February 13, 2012 (edited) I tested it now and it working only if rename cmd. local uTimers = { } function Chopper ( player ) local Account = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..Account, aclGetGroup ( "Admin" ) ) then local Px, Py, Pz = getElementPosition ( player ) local Rx, Ry, Rz = getElementRotation ( player ) if isPedInVehicle( player ) then local vehicle = getPedOccupiedVehicle ( player ) destroyElement ( vehicle ) end local vehicle2 = createVehicle ( 497, Px, Py, Pz, Rx, Ry, Rz ) if isTimer( uTimers[ player ] ) then killTimer( uTimers[ player ] ) end uTimers[ player ] = setTimer( function( player,vehicle ) warpPedIntoVehicle ( player, vehicle ) end, 100, 1,player,vehicle2 ) else outputChatBox ( "You can not execute this command!", player ) end end addCommandHandler ( "_test", Chopper ) addEventHandler( 'onPlayerQuit',root, function( ) uTimers[ source ] = nil end ) cmd:/_test Edited February 13, 2012 by Guest
Kenix Posted February 13, 2012 Posted February 13, 2012 No problem. I tested it now and it working only if rename cmd. This is strange rly.
Castillo Posted February 13, 2012 Posted February 13, 2012 What exactly doesn't work? I just tested it and it destroyed my vehicle.
Kenix Posted February 13, 2012 Posted February 13, 2012 Not work if use test cmd. But another name for cmd work
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