Jump to content

Suicide [SCRIPT]


PaulDK

Recommended Posts

Hey Dude's i Need Help Can You Help me :D i want if i type /suicide then i move it will cancel but if i not move it will not cancel

thanks in Advance :D

Here's the Script :D

function commitSuicide (sourcePlayer)

local moveState = getPedMoveState(sourcePlayer)

local seconds = 10

if moveState then

outputChatBox("#FFFF00[ADMIN BOT] You Has Move Attempting Suicide Failed", sourcePlayer ,0, 0, 0, true)

cancelEvent()

end

if not moveState then

outputChatBox("#FFFF00[ADMIN BOT]Wait 10 seconds You Has Been Frozen", sourcePlayer,255,255,255,true)

setTimer(function()

seconds = seconds-1

if seconds<=0 then

killPed(sourcePlayer, sourcePlayer)

end

end,1000,seconds)

end

end

addCommandHandler("suicide", commitSuicide)

Link to comment
function commitSuicide(thePlayer, cmd) 
    if not getElementData(thePlayer, "suicide") then 
        setElementData(thePlayer, "suicide", true) 
        seconds = 10 
        suicideTimer = setTimer(function(thePlayer) 
            if seconds > 1 then 
                seconds = seconds-1 
            else 
                killPed(thePlayer) 
                killTimer(suicideTimer) 
                setElementData(thePlayer, "suicide", false) 
            end 
        end, 1000, 0, thePlayer) 
    else 
        outputChatBox("#FFFF00[ADMIN BOT]You are already attempting to suicide! Please wait!", thePlayer, 255, 0, 0, true) 
    end 
end 
addCommandHandler("suicide", commitSuicide) 
  
setTimer(function() 
    for i,v in ipairs(getElementsByType("player")) do 
        if getElementData(v, "suicide") then 
            if getPedMoveState(thePlayer) ~= "stand" and getPedMoveState(thePlayer) ~= "crouch" then 
                if isTimer(suicideTimer) then 
                    killTimer(suicideTimer) 
                    setElementData(v, "suicide", false) 
                    outputChatBox("#FF0000[ADMIN BOT]You attempted to move! Suicide cancelled!", v, 255, 0, 0, true) 
                end 
            end 
        end 
    end 
end, 50, 0) 

Try that

Link to comment
  • Moderators

getPedMoveState is clientside. You can't use that at serverside.

Just simply replace:

local moveState = getPedMoveState(sourcePlayer) 

local moveState  = getDistanceBetweenPoints3D ( 0, 0, 0, getElementVelocity ( sourcePlayer ) ) > 1 
  
Link to comment

try this, haven't tested

  
function commitSuicide(src) 
    if src then 
        if getElementData(src, "suicide") == false then 
            -- message when player writes the command if he is not already suiciding 
            toggleAllControls(src, false) 
            setElementData(src, "suicide", true) 
            sec = 10 
            local suicideTimer = setTimer(function(plr) 
                if sec <= 0 then 
                    killPed(plr) 
                    killTimer(suicideTimer) 
                    setElementData(plr, "suicide", false) 
                    toggleAllControls(src, true) 
                    -- message when suicided 
                else 
                    sec = sec - 1 
                end 
            end, 1000, 0, src) 
        else 
            -- message if player is already committing suicide but tries to enter the command 
        end 
    end 
end 
addCommandHandler("suicide", commitSuicide) 
  

Link to comment
  • Moderators
Dude Script Doesn't Work... Anyone Give Me The Right Script

Don't call me dude and good luck with your infinity timers. :P

I am not here to script for you, I only give help to the ones that deserve it.

Link to comment
try this, haven't tested

  
function commitSuicide(src) 
    if src then 
        if getElementData(src, "suicide") == false then 
            -- message when player writes the command if he is not already suiciding 
            toggleAllControls(src, false) 
            setElementData(src, "suicide", true) 
            sec = 10 
            local suicideTimer = setTimer(function(plr) 
                if sec <= 0 then 
                    killPed(plr) 
                    killTimer(suicideTimer) 
                    setElementData(plr, "suicide", false) 
                    toggleAllControls(src, true) 
                    -- message when suicided 
                else 
                    sec = sec - 1 
                end 
            end, 1000, 0, src) 
        else 
            -- message if player is already committing suicide but tries to enter the command 
        end 
    end 
end 
addCommandHandler("suicide", commitSuicide) 
  

bro thank you very much i fix it :D:)

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