Jump to content

race-dd collision script problem


Fury

Recommended Posts

Posted

client:

local vehModel = nil 
local screen_x, screen_y = guiGetScreenSize() 
local font = "bankgothic" 
local scale = screen_x / 1000 
local message = "" 
local messWidth = 1 
local messHeight = 1 
addEventHandler("onClientVehicleCollision", root, 
function(collider) 
    if collider then 
        if getElementType(collider)=="vehicle" and getElementHealth(source)>250 and isElementInWater(source)==false then 
            triggerServerEvent("vehicleCollision", source, collider) 
        end 
    end 
end 
) 
addEvent("showDeathMess", true) 
addEventHandler("showDeathMess", getRootElement(), 
function(theKiller) 
    if(source ~= getLocalPlayer())then return end 
    addEventHandler("onClientRender", getRootElement(), kill) 
    message = "Killed by: "..theKiller 
    messWidth = dxGetTextWidth(message, scale, font) 
    messHeight = dxGetFontHeight(scale, font) 
    setTimer(function() removeEventHandler("onClientRender", getRootElement(), kill) end, 5000, 1) 
end) 
function kill() 
    dxDrawText(message, screen_x/2 - messWidth/2, screen_y/2 - messHeight/2, screen_x, screen_y, tocolor(255, 0, 0, 150), scale, font) 
end 

server:

function collider ( collider ) 
    outputChatBox ( "Killer: " .. collider, source ) 
    local acc = getPlayerAccount( collider ) 
    local kills = getAccountData( acc,"kills" ) or 0 
    setAccountData( acc,"kills", kills+1) 
    triggerClientEvent("showDeathMess", source, collider) 
end 
addEvent( "vehicleCollision", true ) 
addEventHandler( "vehicleCollision", getRootElement(), collider ) 
function wasted() 
    local acc = getPlayerAccount( source ) 
    local deaths = getAccountData( acc,"deaths" ) or 0 
    setAccountData( acc,"deaths", deaths+1) 
end  
addEventHandler( "onPlayerWasted", getRootElement(), wasted ) 

what i am doing wrong? :/

Posted
getAcc data is when player exit setAcc data is when player login

well i havent problem on account things for now. i cant define the "killer"

Posted
@Vendetta: What is the problem exactly? does it output any debugscript error?

when i hit some car its output:

c894p.png

read onPlayerWasted on wiki here u can see how to define it

i wanna define the "killer" not the "killed"

Posted
That's because is a element, you should use: tostring ( ):
outputChatBox ( "Killer: ".. tostring ( collider ), source ) 

its dont output chat anything.

c89g0.png

also dont show the killer on screen :/

Posted
That's because is a element, you should use: tostring ( ):
outputChatBox ( "Killer: ".. tostring ( collider ), source ) 

Output an element in Chat Box? If it's a player element you should use getPlayerName, not tostring.

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