Jump to content

next and previous weapon


MultiNo

Recommended Posts

Posted
I do not know if this is possible, but how can I get my previous weapon and the next weapon?

an example?

'press E and Q '

- New , Kill System

- New, GameMode Intro

- Leve / Exp System

- New nametag showing style

- New , Hud For Players

- Skin Selection from SA-MP

- Money System / Buy Weapons

- Drop Weapons

- New, Flood System

- New , Group Assign

- Gun license For Weapons

- Random Rule System For Money

Posted
I wanted a function for this

to create a HUD, just like this picture http://4.bp.blogspot.com/_zNnMHNDuLso/S ... 0/HUD1.jpg

getPedWeapon 

- New , Kill System

- New, GameMode Intro

- Leve / Exp System

- New nametag showing style

- New , Hud For Players

- Skin Selection from SA-MP

- Money System / Buy Weapons

- Drop Weapons

- New, Flood System

- New , Group Assign

- Gun license For Weapons

- Random Rule System For Money

Posted
Use the event
  
onPlayerWeaponSwitch 
  

@ Max: It will only get the current weapon! Not previous .

Yeah , You'r Right , that event should do the job ,

- New , Kill System

- New, GameMode Intro

- Leve / Exp System

- New nametag showing style

- New , Hud For Players

- Skin Selection from SA-MP

- Money System / Buy Weapons

- Drop Weapons

- New, Flood System

- New , Group Assign

- Gun license For Weapons

- Random Rule System For Money

Posted

"onPlayerWeaponSwitch" will not return the next weapon.

You can use these functions:

Client

function getPreviousWeapon() 
    local tempSlot = {} 
    local curSlot = getPedWeaponSlot(localPlayer) 
    if (curSlot == 0) and (getPedWeapon(localPlayer) == 0 or getPedWeapon(localPlayer) == 1) then 
        curSlot = 13 
    end 
     
    tempSlot["ID"] = 12 + 1 
    repeat 
        tempSlot["ID"] = tempSlot["ID"]-1 
    until (tempSlot["ID"] < curSlot) and not (tempSlot["ID"] ~= 0 and getPedWeapon(localPlayer, tempSlot["ID"]) == 0) 
    return getPedWeapon(localPlayer, tempSlot["ID"]) 
end 
  
function getNextWeapon() 
    local tempSlot = {} 
    local curSlot = getPedWeaponSlot(localPlayer) 
    if (curSlot == 12) then 
        curSlot = - 1 
    end 
     
    tempSlot["ID"] = - 1 
    repeat 
        tempSlot["ID"] = tempSlot["ID"] + 1 
        if tempSlot["ID"] == 13 then 
            tempSlot["ID"] = -1 
            curSlot = -1 
        end 
    until (tempSlot["ID"] > curSlot) and not (tempSlot["ID"] ~= 0 and getPedWeapon(localPlayer, tempSlot["ID"]) == 0) 
    return getPedWeapon(localPlayer, tempSlot["ID"]) 
end 

I don't know if it's the best way to do that, but it should work without problems.

Please do not PM me with scripting related question nor support, use the forums instead.

Posted

I tried this but not working

    if ( 'getPreviousWeapon' == 1 ) then  
        dxDrawImage ( x, y, x, y, "img/1.png" ) 
    end 

Posted

You aren't using it as a function.

Replace:

if ( 'getPreviousWeapon' == 1 ) then 

with:

if ( getPreviousWeapon ( ) == 1 ) then 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

You're welcome.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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