Jump to content

anti forward


Newbie

Recommended Posts

Hello.

I am trying to do anti forward script for infernus.

If player goes forward in this case he press "W"

car blows.

function blowNoobs ( thePlayer ) 
  id = getVehicleID ( theVehicle ) 
  if id == 411 then 
      blowVehicle ( source ) 
      outputChatBox ( "You're noob..", getRootElement(), 255, 0, 0, true ) 
   end 
end 
bindKey ( "W", blowNoobs )    

bad argument bind key

Edited by Guest
Link to comment
function blowNoobs ( thePlayer ) 
  local theVehicle = getPedOccupiedVehicle ( thePlayer ) 
  id = getVehicleID ( theVehicle ) 
  if id == 411 then 
      blowVehicle ( source ) 
      outputChatBox ( "You're noob..", getRootElement(), 255, 0, 0, true ) 
   end 
end 
bindKey ( "W", blowNoobs )    

Hmmm ?

Link to comment

Made it!

function blowNoobs ( thePlayer ) 
  local theVehicle = getPedOccupiedVehicle ( thePlayer ) 
  id = getVehicleID ( theVehicle ) 
  if id == 411 then 
      blowVehicle ( theVehicle ) 
      outputChatBox ( "You're noob..", getRootElement(), 255, 0, 0, true ) 
      else 
      outputChatBox ( "Test", getRootElement(), 255, 0, 0, true )      
   end 
end 
addCommandHandler ( "nx", blowNoobs ) 

But now i need to make it at a bind not as command, could any one help ?

I got bad argument while testing with bind key

Link to comment

Good. Also I advise you to use getElementModel instead of getVehicleID, because getVehicleID is an old function and will maybe not exist in future versions. (Atleast that is what they say at Wiki)

EDIT:

Search here for codes: https://wiki.multitheftauto.com/wiki/Main_Page

(Left side: Server/Client functions/event)

Use:

bindKey 

But also note that players can change their driving key to another key. At this moment I don't know how to get this key.

Link to comment
function blowNoobs(thePlayer) 
    local theVehicle = getPedOccupiedVehicle(thePlayer) 
    if (theVehicle) then 
        local id = getElementModel(theVehicle) 
        if (id == 411) then 
            blowVehicle(source) 
            outputChatBox("You're noob..", getRootElement(),255,0,0,true) 
        end 
    end 
end 
  
function onPlayerJoin() 
    bindKey(source,"W","down",blowNoobs) 
end 
addEventHandler("onPlayerJoin",getRootElement(),onPlayerJoin) 

But wouldn't it be better to just disable front movement when you enter the vehicle? With 'toggleControl'.

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...