Ive been trying to remake a script, to replace ulx, for my clan servers and I cant figure out how to do the tp command.
Urrghh Ive used Player.GetShootPos and Player.AimVector but how would I get the max distance between anything in the world and that vector?
Ur lawl I am a bit of a lua noob, could you provide an example? :3
[editline]05:16PM[/editline]
Note: I did look on the wiki, just someone has removed endpos etc from the vectors page.
[lua]local tr = ply:GetEyeTrace();
ply:SetPos(tr.HitPos + Vector(0, 0, 25))[/lua]
That is a very simple example, ply is the player object.
Thanks <3
[editline]05:47PM[/editline]
I think the vectors page on the wiki needs updating with better examples and explanations, its not very clear unless you do like a-level physics+maths haha.
[QUOTE=djratboy;16541689]Thanks <3
[editline]05:47PM[/editline]
I think the vectors page on the wiki needs updating with better examples and explanations, its not very clear unless you do like a-level physics+maths haha.[/QUOTE]
I'm doing the Scottish equivalent, and I don't understand it :P
All I know is it's Vector(z , x , y)
I think...
I just finished A Level physics ad A Level maths. I haven't got my results yet though.
Lawl urr I tried teleporting a player (equiv of ulx goto):
player.SetPos(plya:GetPos())
Player being the person who called the argument and plya being the player to teleport to. It doesnt work - nothing happens - no errors no thing :(
Any ideas? :3
You're overriding the player library and not calling the function correctly, choose a different name.
No its fine lawl, I have used the same name in like ten other functions.
[editline]07:14PM[/editline]
Even changed it to something else, didnt work. Lawl and also urrr im recycling old snippets from when BlackOps taught me the basics of lua - blame him :D
But yeah doesnt make a difference.
I don't think you actually have an idea what you're doing. Post all your code.
function fh_goto( player, command, arguments )
if !player:IsAdmin() then
Sendtext("[FH] Not admin go away ^_^", player)
return
end
local plya = get_player(arguments[1])
if plya == nil then
Sendtext("Player not found: " .. arguments[1], player)
return
end
player.SetPos(plya:GetPos())
end
concommand.Add( "fh_goto", fh_goto )
[editline]07:26PM[/editline]
Also with vectors - nope. Never done vectors ;D
[lua]function fh_goto( ply, command, arguments )
if ( !ply:IsAdmin( ) ) then
Sendtext( "[FH] Not admin go away ^_^", ply )
return
end
local plya = get_player( arguments[1] )
if ( plya == nil ) then
Sendtext( "Player not found: " .. arguments[1] , ply )
return
end
ply:SetPos( plya:GetPos( ) + Vector( 0, 0, 128 ) )
end
concommand.Add( "fh_goto", fh_goto )[/lua]
Thanks...I didnt use your code as such...I used:
ply:SetPos( plya:GetPos( ) + Vector( 0, 0, 128 ) )
And renamed ply to player and it works :D I might change the vector though...no idea why it didnt work in the first place. Thanks.
[editline]07:32PM[/editline]
O btw vectors etc, is it X,Y,Z or what the guy said above? (ZXY)
That's exactly what I did, except for the better formatting.
[lua]player.SetPos( plya:GetPos( ) )[/lua]
This tells Lua to set the position of the entity "plya:GetPos( )" to "nil". : means that the identifier before the : is the first argument. So, if you would still want to do it without a :, you'd do this:
[lua]player.SetPos( player, plya:GetPos( ) )[/lua]
O crap I put a "." xD
I am too use to .net :P
Thanks :D
Also, player is infact a libary. By naming the variable that, you overwrote the libary making plya:GetPos() == nil
This doesnt seem to work (from the wiki too):
function playerRespawn( ply )
Sendtextall("Respawn...")
if HasJail( ply ) == true then
GiveJail( ply )
end
Sendtextall(ply:GetName())
end
hook.Add( "PlayerSpawn", "playerRespawn", playerRespawn )
I even added a bit at the start to send text to everyone - incase it was e.g. GiveJail causing an error but nothing - that function works anyways and so does HasJail.
So, what exactly is the problem?
[QUOTE=|FlapJack|;16544882]Also, player is infact a libary. By naming the variable that, you overwrote the libary making plya:GetPos() == nil[/QUOTE]
Wait what? _R.Player is the Library!
oh you mean those 5 functions xD. Its only overwritten locally!
It's common practice to not override any libraries, even if they are only overridden locally.
The problem is that I have written a jail system and I want it so when the player respawns, their jail gets reapplied (weapons taken etc):
This doesnt seem to work (from the wiki too):
function playerRespawn( ply )
Sendtextall("Respawn...")
if HasJail( ply ) == true then
GiveJail( ply )
end
Sendtextall(ply:GetName())
end
hook.Add( "PlayerSpawn", "playerRespawn", playerRespawn )
Exepct this code doesnt work...nothing happens. I even added a line to send everyone text when a player respawned - also failed so its not due to error within the actual function.
Sorry, you need to Log In to post a reply to this thread.