Castillo Posted May 5, 2011 Posted May 5, 2011 Hey there, i don't use to ask for help, but right now i'm a bit confused, this function keeps returning wrong, function checkWeapon(player,cat) melee = {1,10} primary = {3,5,6} secondary = {2,4} projectiles = {7,8} if cat == "Melee" then for i,v in pairs(melee) do if getPedTotalAmmo ( player, v ) == 0 then return true else outputChatBox("You already have a weapon of this category!",player,255,0,0) return false end end elseif cat == "Primary" then for i,v in pairs(primary) do if getPedTotalAmmo ( player, v ) == 0 then return true else outputChatBox("You already have a weapon of this category!",player,255,0,0) return false end end elseif cat == "Secondary" then for i,v in pairs(secondary) do if getPedTotalAmmo ( player, v ) == 0 then return true else outputChatBox("You already have a weapon of this category!",player,255,0,0) return false end end elseif cat == "Projectiles" then for i,v in pairs(projectiles) do if getPedTotalAmmo ( player, v ) == 0 then return true else outputChatBox("You already have a weapon of this category!",player,255,0,0) return false end end end end It's used to check if i have a weapon in the desired category or not, but somehow it keeps returning that i don't have, any help is appreciated. Thanks in advance. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Jaysds1 Posted May 5, 2011 Posted May 5, 2011 Is this a client script or a server script? My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Castillo Posted May 5, 2011 Author Posted May 5, 2011 It's a server-side script. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Jaysds1 Posted May 5, 2011 Posted May 5, 2011 ok My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Jaysds1 Posted May 5, 2011 Posted May 5, 2011 is there a client-script? My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Castillo Posted May 5, 2011 Author Posted May 5, 2011 Why do you ask? the problem is on the code i posted. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Jaysds1 Posted May 5, 2011 Posted May 5, 2011 did you try putting in /debugscript 3 in-game? My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Castillo Posted May 5, 2011 Author Posted May 5, 2011 Do you think i'm a newbie scripter? i have about 1,5 - 2 years scripting in MTA, is that a joke? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Jaysds1 Posted May 5, 2011 Posted May 5, 2011 no My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Cadu12 Posted May 5, 2011 Posted May 5, 2011 checkWeapon(source, "Melee") Im not sure Ingame nick: Cadu12
Castillo Posted May 5, 2011 Author Posted May 5, 2011 What...? I use this function on my script like this: if checkWeapon(source,cat,model,slot) then San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Cadu12 Posted May 5, 2011 Posted May 5, 2011 function checkWeapon(player, cat) = checkWeapon(source, "Melee") function checkWeapon(player, cat, cat2) = checkWeapon(source, "Melee", "Primary") etc Ingame nick: Cadu12
Castillo Posted May 5, 2011 Author Posted May 5, 2011 This function checks for what category i want to check, then it checks if i have the weapons and returns true or false. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Cadu12 Posted May 5, 2011 Posted May 5, 2011 Change to "if not getPedTotalAmmo ( player, v ) >= 1 then" in your function. Ingame nick: Cadu12
Castillo Posted May 5, 2011 Author Posted May 5, 2011 That won't work, outputs an error: "attempt to compare number with boolean". San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Cadu12 Posted May 5, 2011 Posted May 5, 2011 Try "if not tonumber(getPedTotalAmmo ( player, v )) >= 1 then" Ingame nick: Cadu12
Castillo Posted May 5, 2011 Author Posted May 5, 2011 lol, i tryied that already, now i'm using this: if getPedTotalAmmo ( player, v ) == 0 or not getPedTotalAmmo(player) or not getPedWeapon(player,v) then, for now seems to work, but it may get buggy after a while. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Cadu12 Posted May 5, 2011 Posted May 5, 2011 Solidsnake, are you making your own gamemode? =D Ingame nick: Cadu12
Castillo Posted May 5, 2011 Author Posted May 5, 2011 Uhm, no.. i've closed my RPG server long time ago, remade some stuff from it some weeks ago, but nothing else, still thinking if i will re-open it or not, but this script isn't for me really, just for my client (working for a guy for $$). San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Cadu12 Posted May 5, 2011 Posted May 5, 2011 Race is better , im making my own systems Ingame nick: Cadu12
Castillo Posted May 6, 2011 Author Posted May 6, 2011 This thing is still bugged , i'm out of ideas, i don't know why it won't work, here's the new code. Edit: Remp helped me in the IRC channel, and seems to work fine his code, thanks to everyone, specially to Remp San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now