Jump to content

It can?


Scripting

Recommended Posts

I want ask if I can do that:

set a name to weapon

server side:

super = giveWeapon(source,31,1000)

function detect(player,weapon,super)

if ( weapon == "m4" ) then

killPed(player)

outputChatBox("Don t use Super Weapon",player,255,255,0,true)

end

end

addEventHandler(onPlayerFire,getRootElement(),detect)

Link to comment

First, yes you can make this. Just create a table with id and name you want and use like "table[id].name".

Second, your code is wrong.

Third, tabulate your code and use LUA tags.

Edit: I've not seen all, I thought that it's other thing. By your way, you can't. You must use ID because parameter "weapon" is a real number, not a string :D

Edited by Guest
Link to comment
local root = getRootElement() 
function detect() 
giveWeapon ( source, 31, 1000 ) 
if ( weapon == 31 ) then 
killPed(source) 
outputChatBox("Don t use Super Weapon",source,255,255,0,true) 
end 
end 
addEventHandler("onPlayerWeaponSwitch", root, detect) 

You know what are you doing? Everytime you change weapon, you will get killed because when player get weapon, player weapon will be the weapon you got now. Also "weapon" is nil.

So:

addEventHandler ( 'onPlayerWeaponSwitch', root, 
    function ( _, nWeapon ) 
        if ( nWeapon == 31 ) then 
            killPed ( source ); 
            outputChatBox ( 'You cannot use this weapon!', source, 255, 255, 255, false ); 
        end 
    end 
) 

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