[QUOTE=Internet1001;45456295]Because you're only checking timeLeft once, when the file is loaded.
Either put it in your timer, or just call StartVote() with a timer like this:
[lua]timer.Create( "VoteTimer", timeLeft, 1, function() StartVote() end )[/lua]
So it'll call the function after the time is over, which is much easier.
Also, you don't need to timer.Start() after creating a timer, it starts automatically.[/QUOTE]
Thanks.
So I am making a map vote system, the server has a timer and when it runs out I presume I need to then run some code client side in order to give them voting options.
How do I send the possible options to the client, get their input and then return it to the server?
You can use the [url=http://wiki.garrysmod.com/page/Net_Library_Usage]net library[/url] for communications between server/clients. The examples on that page should show you what you need.
I recommend you only send the file names of the maps, do some client side magic to give it a decent name.
How can I check that something is partially equal to something. In my case it is data returned from a mysql database that I want to compare to a players steam id, however I cannot just do 'if data == ply:SteamID()' because it will false because there is more than one steam ID in the data returned by the query.
Thanks. Also let me know if you don't understand what I am asking, it really has nothing to do with the database at all.
[QUOTE=TheDoggy;45458383]How can I check that something is partially equal to something. In my case it is data returned from a mysql database that I want to compare to a players steam id, however I cannot just do 'if data == ply:SteamID()' because it will false because there is more than one steam ID in the data returned by the query.
Thanks. Also let me know if you don't understand what I am asking, it really has nothing to do with the database at all.[/QUOTE]
What type is "data"? Is it a table of Steam IDs?
[QUOTE=jackwilsdon;45458408]What type is "data"? Is it a table of Steam IDs?[/QUOTE]
Yes
[QUOTE=TheDoggy;45458418]Yes[/QUOTE]
You could iterate the table to check if it contains it, or use table.Contains(tbl, id), but I'm not sure which is faster.
To iterate the table, use [LUA]for _, id in pairs( data ) do
if id == ply:SteamID() then
-- Do whatever
end
end[/LUA]
Hmmm, thats odd, doesn't seem to be working..
My code:
[CODE]
function findinfo:onSuccess( data )
PrintTable( data )
if table.HasValue(data, ply:SteamID()) then
print("Player data found for:", ply:SteamID())
else
print("Player data not found for:", ply:SteamID(), "creating.....")
end
end[/CODE]
Result:
[IMG]http://puu.sh/algHL/638158aa1e.png[/IMG]
Tried iteration too, which also didn't seem to work.
[QUOTE=TheDoggy;45458604]Hmmm, thats odd, doesn't seem to be working..
My code:
[CODE]
function findinfo:onSuccess( data )
PrintTable( data )
if table.HasValue(data, ply:SteamID()) then
print("Player data found for:", ply:SteamID())
else
print("Player data not found for:", ply:SteamID(), "creating.....")
end
end[/CODE]
Result:
[IMG]http://puu.sh/algHL/638158aa1e.png[/IMG]
Tried iteration too, which also didn't seem to work.[/QUOTE]
[lua]
for k,v in pairs(table) do
if(v.steam_id == ply:SteamID()) then
--do stuff
break
end
end
[/lua]
[QUOTE=MeepDarknessM;45458677][lua]
for k,v in pairs(table) do
if(v.steam_id == ply:SteamID()) then
--do stuff
break
end
end
[/lua][/QUOTE]
Thanks mate, really appreciate it :) Worked like a charm!
How do I tell an NPC (specifically an npc_fastzombie) to move to a desired location using lua?
[QUOTE=ROFLBURGER;45459975]How do I tell an NPC (specifically an npc_fastzombie) to move to a desired location using lua?[/QUOTE]
Take a look at [URL=http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index6826.html]NPC.SetSchedule[/URL]
[QUOTE=jackwilsdon;45460048]Take a look at [URL=http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index6826.html]NPC.SetSchedule[/URL][/QUOTE]
I looked at this before I asked and it didn't even work for me.
[QUOTE=ROFLBURGER;45460079]I looked at this before I asked and it didn't even work for me.[/QUOTE]
Could you post the code you tried?
[QUOTE=jackwilsdon;45460088]Could you post the code you tried?[/QUOTE]
[code] local minion = ents.Create("npc_fastzombie")
minion:SetPos(self.Owner:GetPos() + self.Owner:GetForward()*50)
minion:SetAngles(self.Owner:GetAngles())
minion:SetOwner(self.Owner)
minion:AddEntityRelationship(self.Owner, D_LI, 99 )
minion:SetCurrentWeaponProficiency( WEAPON_PROFICIENCY_PERFECT )
minion:SetKeyValue("spawnflags","256")
minion:Spawn()
minion:SetHealth(self.MinionHealth)
minion:SetLastPosition( self.Owner:GetEyeTrace().HitPos + Vector(0,0,25) )
minion:SetSchedule( SCHED_FORCED_GO_RUN )
[/code]
[QUOTE=ROFLBURGER;45460125][code] local minion = ents.Create("npc_fastzombie")
minion:SetPos(self.Owner:GetPos() + self.Owner:GetForward()*50)
minion:SetAngles(self.Owner:GetAngles())
minion:SetOwner(self.Owner)
minion:AddEntityRelationship(self.Owner, D_LI, 99 )
minion:SetCurrentWeaponProficiency( WEAPON_PROFICIENCY_PERFECT )
minion:SetKeyValue("spawnflags","256")
minion:Spawn()
minion:SetHealth(self.MinionHealth)
minion:SetLastPosition( self.Owner:GetEyeTrace().HitPos + Vector(0,0,25) )
minion:SetSchedule( SCHED_FORCED_GO_RUN )
[/code][/QUOTE]
What map are you testing this on? I believe it has to be noded (e.g. gm_construct).
My problem(the weapon is blue):
[QUOTE][IMG]http://cloud-4.steampowered.com/ugc/576776534415642279/5493D8DD324FD444AD9C92457F82DF06F9C20C12/1024x576.resizedimage[/IMG][/QUOTE]
the code i used:
[CODE]
local boneindex = p:LookupBone("ValveBiped.Bip01_Spine2")
if boneindex then
local pos, ang = p:GetBonePosition(boneindex)
ang:RotateAroundAxis(ang:Forward(),0)
mdl:SetRenderOrigin(pos+(ang:Right()*4)+(ang:Forward()*-5));
ang:RotateAroundAxis(ang:Right(),-15)
mdl:SetRenderAngles(ang);
mdl:DrawModel();
end
[/CODE]
There is a way to set the player color without set the color of Entitys created on player's bones on the hook PostPlayerDraw?
[QUOTE=jackwilsdon;45460260]What map are you testing this on? I believe it has to be noded (e.g. gm_construct).[/QUOTE]
It was on a noded map, I changed it to gm_construct just to be sure and it doesn't work. Ai is enabled.
[code]
local limits = {
-- [1] [2] [3] [4]
--"example", "groupname", "limitinnumber", "thelimitname"
"thrusters", "Owner", "3", "Thruster"
}
hook.Add( "CanTool", "proplimit", function(ply)
for __,ply in pairs(limits, player.GetAll()) do
if ply:GetCount( [1] ) > [3] and ply:IsUserGroup([2]) then
ply:ChatPrint("You've hit the" ..[4].. "Limit")
return false
end
end)
[/code]
I can only place one, then it says i hit the limit. any idea?
[QUOTE=74pantera;45461705][code]
local limits = {
-- [1] [2] [3] [4]
--"example", "groupname", "limitinnumber", "thelimitname"
"thrusters", "Owner", "3", "Thruster"
}
hook.Add( "CanTool", "proplimit", function(ply)
for __,ply in pairs(limits, player.GetAll()) do
if ply:GetCount( [1] ) > [3] and ply:IsUserGroup([2]) then
ply:ChatPrint("You've hit the" ..[4].. "Limit")
return false
end
end)
[/code]
I can only place one, then it says i hit the limit. any idea?[/QUOTE]
I really don't mean to sound harsh, but how are you even running this at all?
1. Doing something like [1] and [3] by itself is not valid Lua syntax (unexpected symbol near '[')
2. You shouldn't need to loop through player.GetAll() during CanTool. It gives you the specific player that tried tooling something.
3. AFAIK pairs() does not take varargs. It takes one table only (please correct me if I am mistaken). Only your limits table is being looped through.
4. You really shouldn't use CanTool to regulate prop limits either. Just because they are tooling something doesn't mean they are spawning it (e.g., updating the settings of an already spawned entity). That is what the following hooks are for in Sandbox:
PlayerSpawnedEffect
PlayerSpawnedNPC
PlayerSpawnedProp
PlayerSpawnedRagdoll
PlayerSpawnedSENT
PlayerSpawnedSWEP
PlayerSpawnedVehicle
PlayerSpawnEffect
PlayerSpawnNPC
PlayerSpawnObject
PlayerSpawnProp
PlayerSpawnRagdoll
PlayerSpawnSENT
PlayerSpawnSWEP
PlayerSpawnVehicle
I'm trying to create a VIP job.
It won't work, I'm using ULX
[td]TEAM_PTHIEF = DarkRP.createJob("Pro Thief", {
color = Color(47, 79, 79, 255),
model = {"models/code_gs/robber/robberplayer.mdl",},
description = [[You use your skills to raid peoples' bases, and get money.]],
weapons = {"keypad_cracker", "lockpick", "rp_pickpocket",},
command = "pThief",
max = 5,
salary = 35,
admin = 0,
vote = false,
hasLicense = false,
customCheck = function(ply) return CLIENT or ply:IsUserGroup("VIP") or ply:IsUserGroup("owner") or ply:IsUserGroup("superadmin+") or ply:IsUserGroup("admin+") or ply:IsUserGroup("mod+") end,
Sorry idk how to use that table thing
Any idea why the quality of this 3D2D text is so bad?
[IMG]http://i.imgur.com/oW1DBTf.jpg[/IMG]
[CODE]
render.PushFilterMag( TEXFILTER.ANISOTROPIC )
render.PushFilterMin( TEXFILTER.ANISOTROPIC )
cam.Start3D2D( pos, ang, 1 )
draw.SimpleText( "Text", "Default", 0, 0, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
cam.End3D2D()
render.PopFilterMag()
render.PopFilterMin()
[/CODE]
Increase font size and decrease 3D2D screen size.
[QUOTE=Robotboy655;45463587]Increase font size and decrease 3D2D screen size.[/QUOTE]Still a little pixelly around the edges but overall much better, thanks.
[IMG]http://i.imgur.com/v61Y9kX.jpg[/IMG]
I'm having a slight issue with animations.
When I use hold-type ar2 aiming down sights, then walk against a wall ( automatically the weapon goes to idle-holdtype, meaning normal for pistols, passive for long-guns ), but if I am crouching when I walk against the wall the player stands up. I have to change hold type while against wall to get the player to aim down sights again.
So, the issue appears that there is no transition from rifle passive, to crouching ( you hunch over ).
But, from crouching passive ( becomes aiming ), to aiming while crouched works perfectly. I did the test using the CS:S M4.
Is there a translation that can be added for this to work, or???
And
How can I set certain bones on the body to remain stationary ( not move at all with the walking / running, jumping / landing animations ). I've tried several things but they always move.
I've tried hard-coding SetBonePosition ( still moves with animation ). I've tried Manipulating, tried using position from matrix, etc..
One of the things is to move one leg at a cant backwards, slow walk, etc for when shot in the leg. It still wants to animate. A few others involving other parts of the body where I'd like the limb / bone to not move with the animation. I was thinking about starting a gesture and stopping it but no clue.
[QUOTE=Acecool;45465208]I'm having a slight issue with animations.
When I use hold-type ar2 aiming down sights, then walk against a wall ( automatically the weapon goes to idle-holdtype, meaning normal for pistols, passive for long-guns ), but if I am crouching when I walk against the wall the player stands up. I have to change hold type while against wall to get the player to aim down sights again.
So, the issue appears that there is no transition from rifle passive, to crouching ( you hunch over ).
But, from crouching passive ( becomes aiming ), to aiming while crouched works perfectly. I did the test using the CS:S M4.
Is there a translation that can be added for this to work, or???
And
How can I set certain bones on the body to remain stationary ( not move at all with the walking / running, jumping / landing animations ). I've tried several things but they always move.
I've tried hard-coding SetBonePosition ( still moves with animation ). I've tried Manipulating, tried using position from matrix, etc..
One of the things is to move one leg at a cant backwards, slow walk, etc for when shot in the leg. It still wants to animate. A few others involving other parts of the body where I'd like the limb / bone to not move with the animation. I was thinking about starting a gesture and stopping it but no clue.[/QUOTE]I'm pretty sure I remember having a similar issue with the passive hold type to where it didn't transition correctly when crouching and I was unable to crouch with the passive hold type set. Although I can't remember whether that was exactly what the problem was, I'm pretty sure it was something along those lines. So I guess your not the only one with that issue.
[QUOTE=ShadowRanger;45465280]I'm pretty sure I remember having a similar issue with the passive hold type to where it didn't transition correctly when crouching and I was unable to crouch with the passive hold type set. Although I can't remember whether that was exactly what the problem was, I'm pretty sure it was something along those lines. So I guess your not the only one with that issue.[/QUOTE]
I may need to disable crouch if the current weapon is passive and player is against a wall. Will at least let the user know their head is sticking out. Thanks!
[QUOTE=HunterFP;45460824]My problem(the weapon is blue):
the code i used:
[CODE]
local boneindex = p:LookupBone("ValveBiped.Bip01_Spine2")
if boneindex then
local pos, ang = p:GetBonePosition(boneindex)
ang:RotateAroundAxis(ang:Forward(),0)
mdl:SetRenderOrigin(pos+(ang:Right()*4)+(ang:Forward()*-5));
ang:RotateAroundAxis(ang:Right(),-15)
mdl:SetRenderAngles(ang);
mdl:DrawModel();
end
[/CODE]
There is a way to set the player color without set the color of Entitys created on player's bones on the hook PostPlayerDraw?[/QUOTE]
Anyone?
I'm looking at trying to detect when something touches a dead player's ragdoll entity, I'm not sure where to start with Ent:Touch .. I can't find any usage examples for it :/
[QUOTE=HunterFP;45466734]Anyone?[/QUOTE]
Couldn't you yust do mdl:SetColor(255, 255, 255, 255) srry if I wrong cause I really yust guess
[QUOTE=frietje2008;45467398]Couldn't you yust do mdl:SetColor(255, 255, 255, 255) srry if I wrong cause I really yust guess[/QUOTE]
Didnt work
Sorry, you need to Log In to post a reply to this thread.