Hazard| Posted July 2, 2014 Posted July 2, 2014 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. If you want a decent paid scripter, don't contact me, I suck.
Castillo Posted July 2, 2014 Posted July 2, 2014 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. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Hazard| Posted July 2, 2014 Author Posted July 2, 2014 It works thanks, but the problem is that now it blows all the players with a big S in their nick, I want it to blow the player only if he uses (S) Could you fix it? Thanks! If you want a decent paid scripter, don't contact me, I suck.
Castillo Posted July 2, 2014 Posted July 2, 2014 Yeah, it's because parentheses are used for paterns, copy my code again and try it. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Hazard| Posted July 2, 2014 Author Posted July 2, 2014 Thank you, works like a charm If you want a decent paid scripter, don't contact me, I suck.
Castillo Posted July 2, 2014 Posted July 2, 2014 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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