Jump to content

(S) kill


Hazard|

Recommended Posts

Hello, I'm wondering how to make this work exactly.

The point is that when a player includes (S) in his nickname, then on the next round (race) his vehicle gets blown and will have to spectate.

  
addEvent("onRaceStateChanging") 
addEventHandler("onRaceStateChanging", root, 
function getPlayerFromPartialName(name) 
    local name = name and name:gsub("#%x%x%x%x%x%x", "(S)"):lower() or nil 
    local theVehicle = getPedOccupiedVehicle ( player ) 
    if name then 
        for _, player in ipairs(getElementsByType("player")) do 
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", "(S)"):lower() 
            if name_:find(name, 1, true) then 
            for key, player in ipairs ( players ) do 
                if ( theVehicle ) then 
                blowVehicle(theVehicle,false) 
            end 
        end 
    end 
end 

I just wrote much shit and I get errors in the debug, I copied the

getPlayerFromPartialName 

from the wiki.

Could you make it work like I want it to work? if so, thanks alot.

Link to comment
addEvent ( "onRaceStateChanging" ) 
addEventHandler ( "onRaceStateChanging", root, 
    function ( state ) 
        if ( state == "Running" ) then -- If the new state is "running" 
            for _, player in ipairs ( getElementsByType ( "player" ) ) do -- Loop all the ingame players 
                if getPlayerName ( player ):find ( "%(%S%)" ) then -- Check if their nickname contains (S) 
                    local theVehicle = getPedOccupiedVehicle ( player ) -- Get the player vehicle 
                    if ( theVehicle ) then -- If he/she is in a vehicle 
                        blowVehicle ( theVehicle, false ) -- Blow it up 
                    end 
                end 
            end 
        end 
    end 
) 

Try it.

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