Jump to content

A quick question about "or".


Galton

Recommended Posts

Posted

Hello, I want to check if the player is holding a uzi or tec9;

if getPedWeapon(client) == 32 or 28 then 

everything else works fine, but my code only works if I'm holding tec9, not uzi. ( 32 = tec9, 28 = uzi)

sadly google didn't help at all.

thanks in advance.

Posted (edited)

EDIT:

use:

if  getPedWeapon(client) == 32 or getPedWeapon(client) == 28  then 

instead of:

if getPedWeapon(client) == 32 or 28 then 

Edited by Guest
Posted
use:
if ( getPedWeapon(client) == 32 or getPedWeapon(client) == 28 ) then 

instead of:

if getPedWeapon(client) == 32 or 28 then 

thanks for replying. sadly it didn't fix the problem.

Posted (edited)
The code is correct :|

this is my code:

function uziCheck () 
local uzistat = getPedStat(client,75) 
if getPedWeapon(client) == 32 or getPedWeapon(client) == 28  then 
    if uzistat == 500 then 
    setPedStat (client, 75, 1000) 
--  outputChatBox ("test: uzi stat: 1000", client)   
    reloadPedWeapon (client) 
    else 
--  outputChatBox ("test: uzi stat: 500", client)        
    setPedStat (client, 75, 500) 
    reloadPedWeapon (client) 
    end 
else 
outputChatBox ("You must be holding Tec9/Uzi in order to change your Tec9/Uzi stat", client) end 
end 

I'm trying to see if I made a mistake, but it looks fine to me.

Edited by Guest
Posted (edited)

EDIT:

Some error in debugscript? remember that if the function is executed by a command it is obvious you did not add the player in the function.

function (client)  
-- Bla bla 
end 

Edited by Guest
Posted

it's server side, uziCheck function is executed by clicking a gui button.

it works perfectly fine when I'm holding tec9. I tried replacing 32 with something else and it also works fine.

Posted
it works perfectly fine when I'm holding tec9. I tried replacing 32 with something else and it also works fine

I see the problem, that is not a problem haha, what happens is you're looking for the player by clicking verify that the player has the gun in his hand.

EDIT: try this

if getPedWeapon(client, 4) == 32 or getPedWeapon(client, 4) == 28  then 

Posted

even tho restarting the resource didn't help (apparently), I tried restarting my server and now it works fine. weird.

anyway, thanks for your help.

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