Jump to content

Can't see eachothers weapons.


ViRuZGamiing

Recommended Posts

Hello,

me and my friend were testing my gamemode but it seems it doesn't kill with 1 hit, when having weapon 22 or 4.

Also we can't see eachother's guns.

Code:

function spawnHandler () 
    giveWeapon(source, 22, 1) 
    giveWeapon(source, 4, 1) 
end 
  
addEventHandler("onPlayerSpawn", getRootElement(), spawnHandler) 
  
function deadHandler (ammo, attacker, weapon, bodypart) 
    if (attacker) then  
        outputChatBox(tostring(getPlayerName(attacker)).." killed "..tostring(getPlayerName(source)).."!") 
         
        local getAmmo = getPedTotalAmmo(attacker, 2) 
        local setAmmo = getAmmo + 1 
        setWeaponAmmo (attacker, weapon, setAmmo) 
    end 
end 
  
addEventHandler ("onPlayerWasted", getRootElement(), deadHandler) 
  
validValues = 
{ 
    [4] = true, 
    [22] = true 
} 
  
function oneHit (attacker, weapon) 
    if (attacker) then  
        if validValues[weapon] then 
            killPed (source) 
        else  
            outputChatBox("[ERROR] 2: No valid weapon!") 
        end 
    else  
        outputChatBox("[ERROR] 1: No valid attacker!")  
    end 
end  
  
addEventHandler ("onPlayerDamage", getRootElement(), oneHit) 

Regards ViRuZ

Link to comment

Have you changed the model of weapon 22 and 4? if so then there maybe a bug in weapon mod that makes you unable to see each other's weapon.

and about the onehit , try that:

also I made a debug string to tells you the weapon ID

  
function oneHit (attacker, weapon) 
    if (attacker) then 
        outPutDebugString(" weapon id is "..weapon.." ")  
        if (weapon == 22 or weapon == 4)  then 
            killPed (source) 
        else 
            outputChatBox("[ERROR] 2: No valid weapon!") 
        end 
    else 
        outputChatBox("[ERROR] 1: No valid attacker!") 
    end 
end  
  

Link to comment

Actually I do, I have both weapons changed with a client side script.

function loadSkins() 
    txd1 = engineLoadTXD ( "textures/colt45.txd" ) 
    engineImportTXD ( txd1, 346  ) 
    dff1 = engineLoadDFF ( "textures/colt45.dff", 0 ) 
    engineReplaceModel ( dff1, 346  ) 
     
    txd2 = engineLoadTXD ( "textures/knife.txd" ) 
    engineImportTXD ( txd2, 335) 
    dff2 = engineLoadDFF ( "textures/knife.dff", 0 ) 
    engineReplaceModel ( dff2, 335) 
  
    local armytxd = engineLoadTXD ("textures/armyskin.txd") 
    engineImportTXD (armytxd, 2) 
    local armydff = engineLoadDFF ("textures/armyskin.dff", 0) 
    engineReplaceModel (armydff, 2) 
     
    local vectortxd = engineLoadTXD ("textures/vector.txd") 
    engineImportTXD (vectortxd, 7) 
    local vectordff = engineLoadDFF ("textures/vector.dff", 0) 
    engineReplaceModel (vectordff, 7) 
end 
      
function timerFunction () 
    setTimer (loadSkins, 1000, 1) 
end 
  
addEventHandler("onClientResourceStart", resourceRoot, timerFunction) 

Link to comment

This is what I have now as a fix;

function spawnHandler (source) 
    giveWeapon(source, 22, 1, true) 
    giveWeapon(source, 4, 1, false) 
end 
  
function spawnBuffer () 
    setTimer (spawnHandler, 1000, 1, source) 
end 
  
addEventHandler("onPlayerSpawn", getRootElement(), spawnBuffer) 
  
function deadHandler (ammo, attacker, weapon, bodypart, stealth) 
    if (attacker) then  
        outputChatBox(tostring(getPlayerName(attacker)).." killed "..tostring(getPlayerName(source)).."!") 
        if (weapon) then 
            takeWeapon(attacker, weapon) 
            local getAmmo = getPedTotalAmmo(attacker, 2) 
            local setAmmo = getAmmo + 1 
            giveWeapon (attacker, weapon, setAmmo, true) 
            triggerClientEvent("onPlayerDeadScore", source, attacker, weapon, bodypart) 
        end 
    end 
end 
  
addEventHandler ("onPlayerWasted", getRootElement(), deadHandler) 
  
validValues = 
{ 
    [4] = true, 
    [22] = true 
} 
  
function oneHit (attacker, weapon, bodypart, loss) 
    if (attacker) then 
        if validValues[weapon] then 
            killPed (source, attacker, weapon, bodypart, false) 
        else  
            outputChatBox("[ERROR] 2: No valid weapon!") 
        end 
    else 
        outputChatBox("[ERROR] 1: No valid attacker!")  
    end 
end 
  
addEventHandler ("onPlayerDamage", getRootElement(), oneHit) 
  
function killCmd (thePlayer) 
    killPed(thePlayer) 
end 
  
addCommandHandler("kill", killCmd) 

I get 2 problems,

• No gun received on kill with Knife, but with Pistol it is.

• admin\server\admin_server.lua:1458: Admin security - Client/player mismatch from 192.168.x.x (onElementDataChange score)

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