Welcome, Guest. Please login or register.
Did you miss your activation email?
November 22, 2024, 06:40:13 PM
Home Help Login Register
News: Trouble in Terrorist Town? Site here, forum here.

Zombie Master  |  Other  |  Trouble in Terrorist Town  |  Topic: A couple of coding related questions.
Pages: 1 [2]
Author Topic: A couple of coding related questions.  (Read 11385 times)
phoenixf129
Poster

Posts: 476


I Rise from the Ashes.


« Reply #20 on: January 06, 2011, 04:48:44 PM »

nope


hook.Add("PlayerDeath", "Kill and RDM Checker", function(vic, infl, att)
if (vic.was_headshot == true) then
print("Headpop Debug OK!")
               timer.Simple(0, function()
       local rag = vic.server_ragdoll
       rag:SetNetworkedInt( "InflateSize"..rag:LookupBone("ValveBiped.Bip01_Head1"), -100 )
               end
end
end


Didn't work either... I can't understand why.
« Last Edit: January 06, 2011, 04:53:39 PM by phoenixf129 »

Software Upgrade Paradox - If you improve a piece of software enough times, you eventually ruin it.
Kazaki
Poster

Posts: 25



« Reply #21 on: January 07, 2011, 04:07:44 PM »

ur missing a ")" in the end i think xD

http://ldt-clan.com/forum/forum.php
phoenixf129
Poster

Posts: 476


I Rise from the Ashes.


« Reply #22 on: January 07, 2011, 08:23:16 PM »

Indeed I am. Thanks for spotting! Now I feel like a right numpty. Weird Garry's Mod didn't give me a lua error though. Thanks!

Software Upgrade Paradox - If you improve a piece of software enough times, you eventually ruin it.
Kazaki
Poster

Posts: 25



« Reply #23 on: January 09, 2011, 11:25:14 PM »

Hook 'PlDeath' Failed: [addons\quakesmod2 ttt style\lua\autorun\server\quakerage.lua:52] attempt to call method 'IsActiveTraitor' (a nil value)

This error seems to appear when someone is killed by the World or if some1 is slayn via-admin commands but it only happens sometimes...

this is line 52:

if ( ( Killer:IsActiveTraitor() and Victim:IsActiveTraitor() ) or ( !Killer:IsActiveTraitor() and !Victim:IsActiveTraitor() ) ) and ( Killer ~= Victim ) then


------------

Also a small question: Is it possible to test/use the .GetPData .setPData methods if u run a listen server ?

like on this example that shows a players STEAMID when he leaves:

hook.Add( "PlayerDisconnected", "PlDisc", function( pl )

       for _, v in pairs( player.GetAll() ) do
if ( v:GetPData("ShowSid") == 1 ) then
               v:ChatPrint( pl:GetName().. ": " ..pl:SteamID() )
end
       end

end )

hook.Add( "PlayerSay", "PlSaytwo", function (ply, msg, team)
if msg == "!hidesid" then
ply:SetPData("HideSid",0)
ply:ChatPrint( "Disabled ShowSid" )
end
if msg == "!showsid" then
ply:SetPData("ShowSid",1)
ply:ChatPrint( "Enabled ShowSid" )
end
end )
« Last Edit: January 09, 2011, 11:56:40 PM by Kazaki »

http://ldt-clan.com/forum/forum.php
Kazaki
Poster

Posts: 25



« Reply #24 on: January 10, 2011, 09:05:40 PM »

Better Does Pdata even work lol ?

I have tried everything!

and this:
hook.Add( "PlayerDisconnected", "PlDisctwo", function( pl )

   for _, v in pairs( player.GetAll() ) do
if ( v:GetPData("ShowSid") == 1 ) then
v:ChatPrint( pl:GetName().. ": " ..pl:SteamID() )
end
   end

end )

hook.Add( "PlayerSay", "PlSaytwo", function (ply, msg, team)
if msg == "!hidesid" then
ply:SetPData("ShowSid",0)
ply:ChatPrint( "Disabled ShowSid" )
end
if msg == "!showsid" then
ply:SetPData("ShowSid",1)
ply:ChatPrint( "Enabled ShowSid" )
end


end )


doesn't work =(
« Last Edit: January 10, 2011, 09:23:14 PM by Kazaki »

http://ldt-clan.com/forum/forum.php
Bad King Urgrain
Administrator
*****
Posts: 12276



« Reply #25 on: January 10, 2011, 10:26:00 PM »

Works for me in the karma system. Don't see anything obviously wrong with that code. Then again, you didn't give much info other than "it doesn't work".

Piece of advice, and this goes to anyone asking me questions: I'm not going to test out your code. I will tell you if I see an issue when looking over the code. The more information you give, the more likely I am to see the problem. Pasting a slab of code and going "doesn't work" is not very productive. In fact, it annoys and demotivates me, because it makes it unnecessarily difficult to help.

Add print() statements, see what happens in the code, what the values are of different things. For example, print(v:GetPData("ShowSid")). Now you know if anything is being saved. Does PData work on listen servers? Try it out. This is not rocket science, this is incredibly simple, basic debugging.

From now on, I will not help anyone who either does not try to debug the problem, or does not show he has done so by writing down what he found. It is a complete waste of my time.

Again, the above is directed at nearly every person who has ever asked me a Lua question. I get that the gmod lua community is full of teenagers who are only just learning to program, but come on. Be respectful of the person who is spending his free time helping you, and gather all the information you can to help that person help you.

When you do so, you might find you solve most problems before you even need to ask a question.
Kazaki
Poster

Posts: 25



« Reply #26 on: January 10, 2011, 11:17:31 PM »

Sorry i forgot to mention more details.

Yes the Script is beeing ran ( verified because if I type !showsid or !hidesid I'll get the corrusponding Chatprint ).

The lua file is placed in autorun/server/

I believe that the main problem here is that the PData isn't beeing set. [Hook 'PlDisctwo' Failed: [addons\steamidonleave\lua\autorun\server\steamidtonleave.lua:5] attempt to call global 'GetPData' (a nil value)]

It clearly says in the wiki

http://wiki.garrysmod.com/?title=Player.SetPData

Syntax player.SetPData( String PData, VarValue )

so i this rly doesn't make any sense....
« Last Edit: January 10, 2011, 11:49:42 PM by Kazaki »

http://ldt-clan.com/forum/forum.php
Bad King Urgrain
Administrator
*****
Posts: 12276



« Reply #27 on: January 11, 2011, 11:15:04 AM »

Try checking whether the players are valid. You are using player.GetAll() in the disconnect hook, so the disconnecting player might be gone but still present in the list of players. So check if IsValid(v) and v:IsPlayer() before calling v:GetPData.

It is a strange error, this would be my best guess.
Kazaki
Poster

Posts: 25



« Reply #28 on: January 11, 2011, 01:27:59 PM »

still the same thing... it is simply not working... this works with Entity.SetNetworkedInt but NetworkedInt is not stored... and i don't want players to have to type the command every time a server changes map  or restarts


http://wiki.garrysmod.com/?title=Entity.SetNWInt

-------

EDIT:

nvm! appearently when using the  GetPData  I had to type:
if (v:GetPData("ShowSid") == "1" ) then


"1"
« Last Edit: January 11, 2011, 03:57:38 PM by Kazaki »

http://ldt-clan.com/forum/forum.php
Bad King Urgrain
Administrator
*****
Posts: 12276



« Reply #29 on: January 12, 2011, 01:33:38 PM »

You can also use tonumber(v:GetPData(..)) to get a number out of it. I just noticed that's what I do in the karma code as well, guess I missed it when I looked last time.
Kazaki
Poster

Posts: 25



« Reply #30 on: January 17, 2011, 08:09:11 PM »

Hello again.

I'd like to know if there is any way to confirm that Traitors have lost/won the round in the  TTTEndRound Hook

My objective: If the traitors lose in less than 20 seconds after the round started... every1 gets the message: "The traitors have failed!"

I have tried alooot of stuff and ive concluded that at the TTTEndRound Hook no player can be confirmed as traitor ( *:IsActiveTraitor) using this:

hook.Add( "TTTBeginRound", "TTT_kazquake_beginround", function()

FailTimer = CurTime()

end )


hook.Add( "TTTEndRound", "TTT_kazquake_endround", function()

for _, v in pairs( player.GetAll() ) do
if v:IsActiveTraitor() then
Traitorsalive = Traitorsalive + 1
end
end

--If Traitorsalive == 0, then the traitors lost, ect...

if !Traitorsalive then
Traitorsalive = 0
end

local currenttime = CurTime()
if (Traitorsalive == 0) and ( currenttime < FailTimer + 20 ) then
for _, pla in pairs( player.GetAll() ) do
pla:ChatPrint("The traitors have failed!")
end
end


---- This resulted in the Traitorsalive == 0 always beeing true even when the traitors win ( which is wrong ).

end )


so i was hoping of beeing able to do this in a simpler way.

« Last Edit: January 17, 2011, 08:19:14 PM by Kazaki »

http://ldt-clan.com/forum/forum.php
Bad King Urgrain
Administrator
*****
Posts: 12276



« Reply #31 on: January 17, 2011, 08:21:42 PM »

TTTEndRound has a parameter that tells you who won. Do a search on this subforum for "TTTEndRound" and you'll find about 50 examples where I explain how to use it.
Kazaki
Poster

Posts: 25



« Reply #32 on: January 25, 2011, 03:51:11 PM »

Is it possible to edit fretta's votesystem map list ?

like for example: make it show 5 maps only or pick what maps you want it to show.

http://ldt-clan.com/forum/forum.php
Bad King Urgrain
Administrator
*****
Posts: 12276



« Reply #33 on: January 25, 2011, 04:15:17 PM »

Theoretically, yes, but it would be rather difficult.
Kazaki
Poster

Posts: 25



« Reply #34 on: February 02, 2011, 01:27:03 AM »

actually found a easy way to do it lol

-- in the fretta sv_gmchanger.lua
local AllMaps = file.Find( "maps/*.bsp", true )

--just do this right after
local numofmaps = math.Round(table.Count(AllMaps) / 1.3)
for i=1,numofmaps do
table.remove(AllMaps, math.random(1,table.Count(AllMaps)))
end

--it will remove a percetange of the maps
« Last Edit: February 02, 2011, 01:49:01 AM by Kazaki »

http://ldt-clan.com/forum/forum.php
Pages: 1 [2]
Zombie Master  |  Other  |  Trouble in Terrorist Town  |  Topic: A couple of coding related questions. « previous next »
Jump to:  


Login with username, password and session length

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines
Page created in 0.01 seconds with 18 queries.