[QUOTE=Persious;39483365]Regular expressions are annoying the shit out of me. I'm trying to add a DTextEntry that only allows you to enter a number, else it'll disable a button.
local textmatch = string.match( text, "%d" )
Whenever I enter a number, it still lets me type a character.[/QUOTE]
You don't need regular expressions for that.
[code]if tonumber(TextBox:GetValue()) then
-- it's a number
else
-- it's not a number
end[/code]
Oh for fuck sake. Thanks a lot.
[QUOTE=hellguy;39483476]Anyone? I need help, I don't receive any errors, but still doesn't receive my weapons[/QUOTE]
You're using ULX, they don't use your standard usergroups. Therefore it's not getting past the first if statement, put a print in and check.
[QUOTE=Matt-;39483745]You're using ULX, they don't use your standard usergroups. Therefore it's not getting past the first if statement, put a print in and check.[/QUOTE]
I know that groups don't come as default, that's why I created them in ULX and assigned one of them to me to test the code.
[QUOTE=hellguy;39484151]I know that groups don't come as default, that's why I created them in ULX and assigned one of them to me to test the code.[/QUOTE]
You just completely misread what I said, good job.
Also, I'm trying to make a deagle that only hurt traitors, I call it 1 shot glory, for detectives, what's wrong at this function?
[CODE]function SWEP:PrimaryAttack()
for k, ply in pairs( player.GetAll() ) do
if ( !self:CanPrimaryAttack() ) then return end
if ply:IsActiveTraitor() then self:ShootBullet( 150, 1, 0.01 )
self:TakePrimaryAmmo( 1 )
self:EmitSound("Weapon_Deagle.Single")
self.Owner:ViewPunch( Angle( -1, 0, 0 ) )
end
end
end[/CODE]
This thread is for help with Lua, not spoon feeding you everything. Do you even read what your code is doing? Everytime that deagle is fired it'll loop through every player, check if the weapon can fire and shoot the bullet if the looped player is a traitor. Just think about your code logically.
[QUOTE=Matt-;39483745]You're using ULX, they don't use your standard usergroups. Therefore it's not getting past the first if statement, put a print in and check.[/QUOTE]
i am a extreme noob to lua coding, how would we do this?
ULX groups go under player:GetUserGroup() == "usergroup" - Or at least that works for me.
[QUOTE=Pandaman09;39475356][code]
local query = DB.MySQLDB:query(query)
[/code]
Read that line... does it make sense to you?
[code]
local querySend = DB.MySQLDB:query(query)
[/code]
- SNIp -
That should fix your error. If not then it might be that your calling a "nil" query so you would have to say:
if not IsValid(query) then return end[/QUOTE]
Still hasnt fixed, even with the IsValid ,, Couuld it be the mysql host its self ?
[QUOTE=Matt-;39484316]This thread is for help with Lua, not spoon feeding you everything. Do you even read what your code is doing? Everytime that deagle is fired it'll loop through every player, check if the weapon can fire and shoot the bullet if the looped player is a traitor. Just think about your code logically.[/QUOTE]
Do you even know why this thread exists? I'll read it's description for you, since you can't do it yourself: [CODE]"Lua questions that don't deserve their own thread go here.
This means things like:
How to add jobs in DarkRP,
Where to find PERP,
How to shoot ponies out of a gun."[/CODE]
It means it was made for idiot questions, newbies that don't know much or no lua at all, so isn't it "logic less" to come to a thread that was created itself for newbies to get some help with lua expecting to see people experienced with lua asking help? It's funny how you just come rating everyone dumb like if you were smarter yourself, but if you really were it you wouldn't be expecting to find people experienced with lua coding here asking help at first place, so be a little naive and be at least a little polite when talking to the ones that doesn't know as much lua coding as you, because you were like me and the others once, and you wouldn't have liked a smart*** to come over acting like you and everyone else should know lua like they know how to walk and talk.
You probably think you're the one to decide how far newbies can ask help with lua here, please, go get something better to do : )
PS: If I knew the right order of funcions/etc I wouldn't be asking help here.
EDIT:
Continuing with my subject, after looking at some wiki and guides, I got into a code for my weapon, when it shoots, it should only hurt if the player is a traitor, but it still shoots and kill innocents, detectives even props, etc.. What's wrong with it?
[CODE]function SWEP:PrimaryAttack()for k, ply in pairs( player.GetAll() ) do
if ( !self:CanPrimaryAttack() ) then return end
if ply:IsActiveTraitor() then self:ShootBullet( 150, 1, 0.01 )
self:TakePrimaryAmmo( 1 )
self:EmitSound("Weapon_Deagle.Single")
self.Owner:ViewPunch( Angle( -1, 0, 0 ) )
end
end
end[/CODE]
[editline]5th February 2013[/editline]
[QUOTE=Persious;39485376]ULX groups go under player:GetUserGroup() == "usergroup" - Or at least that works for me.[/QUOTE]
Last time I saw someone using that strings to refer to a usergroup, the code was made for Evolve not ULX, I may be wrong.
Is it possible to modify the damage of an NPC, to be specific "npc_turret_floor".
[QUOTE=Pandaman09;39488669]Is it possible to modify the damage of an NPC, to be specific "npc_turret_floor".[/QUOTE]
Just took me 5 secs to find it out trough google
non-sandbox mod : [url]http://facepunch.com/showthread.php?t=508142[/url]
Sandbox tool : [url]http://www.garrysmod.org/downloads/?a=view&id=35064[/url]
[QUOTE=hellguy;39488724]Just took me 5 secs to find it out trough google
non-sandbox mod : [url]http://facepunch.com/showthread.php?t=508142[/url]
Sandbox tool : [url]http://www.garrysmod.org/downloads/?a=view&id=35064[/url][/QUOTE]
"NEEDS SV_CHEATS SET TO 1"
Won't work well for TTT
I also checked through the lua and there are no options for the floor turret.
[QUOTE=Pandaman09;39488844]"NEEDS SV_CHEATS SET TO 1"
Won't work well for TTT
I also checked through the lua and there are no options for the floor turret.[/QUOTE]
If you check well, even with sv_cheats 1 people can't noclip and stuff like that on ttt for some reason, also, trough simple ulx lua scripts you could block people from using sv_cheats 1 commands, but I don't think anyone would check for sv_cheats 1 anyway.
I wouldn't say that. Before I grew a pair, I use to troll on servers too, and I tried to find any exploit I could use. I also checked all the sk_* commands and none effected the floor turret.
[QUOTE=Pandaman09;39488979]I wouldn't say that. Before I grew a pair, I use to troll on servers too, and I tried to find any exploit I could use. I also checked all the sk_* commands and none effected the floor turret.[/QUOTE]
Maybe turning sv_pure 0 and instaling lua anti-cheat + ULX would turn sv_cheats 0 completely useless for trolls
GG.
But this is still not helping my problem of not being able to set the damage of the turret.
Anyone know how to make an entity (NPC specifically) spawn with a weapon using ents.Create?
Nevermind. Found it on wiki.
Does anyone know how to make the Base Gamemode scoreboard refresh after someone leaves the server? When a player leaves the server, the scoreboard leaves a spot for them on it until someone takes their spot.
@banhfunbags have you checked DarkRP's scoreboard?
Is It Possible To Make It So That For Example, When Player 1 on team one looks at player two on team 2, that person 1 starts losing health?
-snip- HoldTypes are messed up in all/most game-modes I've seen, including TTT.
[lua]
function PANEL:UpdateScoreboard(force)
if not force and not self:IsVisible() then return end
for k, v in pairs(self.PlayerRows) do
if not ValidEntity(k) then
v:Remove()
self.PlayerRows[ k ] = nil
end
end
local PlayerList = player.GetAll()
for id, pl in pairs(PlayerList) do
if not self:GetPlayerRow(pl) then
self:AddPlayerRow(pl)
end
end
-- Always invalidate the layout so the order gets updated
self:InvalidateLayout()
end
[/lua]
You could use this in a timer to check to see if a player is valid, like once ever 10-20 seconds?
Or you could always update it when the player opens it, while that may be more efficient it may also lag a bit when they open the scoreboard, depending on what all your doing.
Edit: I didn't check to see if anyone posted so... this is @ Banhfunbags
How can I set an NPC's idle animation? I'm trying to call self:SetSequence, but it only seems to be playing the animation once.
-snip-
Can anyone help me?
[QUOTE=hellguy;39490458]Can anyone help me?[/QUOTE]
Seriously? It took me about 2 minutes to fix it on my own, by only reading the error stack and using the wiki, it's not that hard. Instead of constantly asking for code, why don't you try to learn it and only ask IF YOU HAVE TO!
I've fixed my vipspawn script, but I can't get this 1 shot glory gun to work, shouldn't hurt innocents, but it does.
[CODE]function SWEP:PrimaryAttack()for k, ply in pairs( player.GetAll() ) do
if ( !self:CanPrimaryAttack() ) then return end
if ply:IsActiveTraitor() then self:ShootBullet( 150, 1, 0.01 )
self:TakePrimaryAmmo( 1 )
self:EmitSound("Weapon_Deagle.Single")
self.Owner:ViewPunch( Angle( -1, 0, 0 ) )
end
end
end[/CODE]
[QUOTE=Pandaman09;39488669]Is it possible to modify the damage of an NPC, to be specific "npc_turret_floor".[/QUOTE] Would something like this work? EDIT: Whoops. Uh, dunno how to format code, it keeps stealing my tabs and line breaks. Just... just take a pastebin. [url]http://pastebin.com/Xz1i0NxL[/url]
[editline]6th February 2013[/editline]
[QUOTE=hellguy;39490878]I've fixed my vipspawn script, but I can't get this 1 shot glory gun to work, shouldn't hurt innocents, but it does. [CODE]function SWEP:PrimaryAttack()for k, ply in pairs( player.GetAll() ) do if ( !self:CanPrimaryAttack() ) then return end if ply:IsActiveTraitor() then self:ShootBullet( 150, 1, 0.01 ) self:TakePrimaryAmmo( 1 ) self:EmitSound("Weapon_Deagle.Single") self.Owner:ViewPunch( Angle( -1, 0, 0 ) ) end end end[/CODE][/QUOTE] Why do you still have that loop in there? Do you know what that does? Regardless, you're going to want to do a trace to see if you're aiming at a traitor, THEN shoot the bullet.
Sorry, you need to Log In to post a reply to this thread.