[QUOTE=Robotboy655;47458978][url]http://wiki.garrysmod.com/page/Panel/SetAllowNonAsciiCharacters[/url][/QUOTE]
I think you misunderstood my question. I can input the special characters just fine, but in the code itself, any special characters are interpreted as �s. I want an é to be kept in my variable as é, not �
[QUOTE=r0uge;47459012]I think you misunderstood my question. I can input the special characters just fine, but in the code itself, any special characters are interpreted as �s. I want an é to be kept in my variable as é, not �[/QUOTE]
That's probably because you want to use multibyte characters as single byte, and that's where you fail.
Willox made a utf8 library for Lua, but I am not sure if he released it or not, you should ask him.
[QUOTE=r0uge;47458955]Is there any way I can get my Lua script to accept UTF-8 characters?
I want to use inputs with letters that have accents, but they are converted to the � symbol.[/QUOTE]
According to ARitz Cracker you have to make sure this is checked in your Lua files. That made it so my gPhone could have a Russian translation
[img]http://i.gyazo.com/a328b47fa4fcd338a4793ec2a085ece4.png[/img]
[QUOTE=Exho;47459229]According to ARitz Cracker you have to make sure this is checked in your Lua files. That made it so my gPhone could have a Russian translation
[img]http://i.gyazo.com/a328b47fa4fcd338a4793ec2a085ece4.png[/img][/QUOTE]
This is required if you use non ascii characters in the file itself, I am not sure if it affects anything when the characters are never in that file.
Having a problem when trying to convert the Combine Control swep base over to Nutscript 1.1.
I have tried and tried to get this to work, but no luck.
[CODE]
[ERROR] gamemodes/hl2rp/entities/weapons/weapon_cc_base/sh_helper.lua:180: bad argument #2 to 'LerpAngle' (Angle expected, got nil)
1. LerpAngle - [C]:-1
2. FreeaimThink - gamemodes/hl2rp/entities/weapons/weapon_cc_base/sh_helper.lua:180
3. unknown - gamemodes/hl2rp/entities/weapons/weapon_cc_base/shared.lua:389
[/CODE]
Happen's right when I try to equip my weapon.
[CODE]self.currentFreeAimOffset = LerpAngle(FrameTime() * 10, self.currentFreeAimOffset, self.freeAimOffset)[/CODE]
This is the line the error points me too. I am not that experienced in coding, so all of this is complicated to me, but any help is appreciated! There is various other errors, but I'll try and solve them one at a time.
self.currentFreeAimOffset is nil.
Do you define it somewhere other then that line?
[QUOTE=Robotboy655;47459377]self.currentFreeAimOffset is nil.
Do you define it somewhere other then that line?[/QUOTE]
[CODE]--[[ freeaim ]]--
function SWEP:FreeaimThink()
local FT = FrameTime()
if SERVER then
-- freeaim stuff (serverside)
if self.useFreeaim then
if not self:InSights() then
local goalOffset, faLimit = self.freeAimOffset, self.freeAimLimit
local delta = self:GetAngularVelocity() * FT * self.freeAimSpeed
local length = (goalOffset.p - delta.p)^2 + (goalOffset.y - delta.y)^2
if length > (faLimit^2) then
local norm1, norm2 = goalOffset:Forward(), (goalOffset - delta):Forward()
local nAng = norm1:AngleEx(norm2) -- angle between the two points
-- we only care to take pitch and yaw
goalOffset.p = nAng.p
goalOffset.y = nAng.y
else
-- no need for fancy maths
goalOffset = goalOffset - delta
end
self.freeAimOffset = goalOffset
else
self.freeAimOffset = Angle(0, 0, 0)
end
end
else
-- freeaim stuff (clientside)
if self.useFreeaim then
if not self:InSights() then
local goalOffset, faLimit = self.freeAimOffset, self.freeAimLimit
local delta = self:GetAngularVelocity() * FT * self.freeAimSpeed
local length = (goalOffset.p - delta.p)^2 + (goalOffset.y - delta.y)^2
if length > (faLimit^2) then
local norm1, norm2 = goalOffset:Forward(), (goalOffset - delta):Forward()
local nAng = norm1:AngleEx(norm2) -- angle between the two points
-- we only care to take pitch and yaw
goalOffset.p = nAng.p
goalOffset.y = nAng.y
else
-- no need for fancy maths
goalOffset = goalOffset - delta
end
self.freeAimOffset = goalOffset
self.currentFreeAimOffset = LerpAngle(FrameTime() * 10, self.currentFreeAimOffset, self.freeAimOffset)
else
self.freeAimOffset = Angle(0, 0, 0)
self.currentFreeAimOffset = LerpAngle(FrameTime() * 10, self.currentFreeAimOffset, self.freeAimOffset)
end
if self.nextFreeAimSync <= CurTime() then -- keep it in sync, just to avoid rounding errors.
-- i realize im trusting the client, but it keeps it from being super jumpy and still keeps it in sync
net.Start("fa_sync_s")
net.WriteAngle(self.freeAimOffset)
net.SendToServer()
self.nextFreeAimSync = CurTime() + 1
end
end
end
end[/CODE]
here is the full code, if it helps, as I edited into my post, I am not THAT experienced, and am only editting this base to work over on Nutscript, so I'm not sure. This is probably a bit advanced for me, but I'm doing it just for the practice and experience.
[QUOTE=Ghost_Sailor;47452951]How would I go about attaching an EffectData to a weapon attachment? I'm trying to recreate the stun baton, and I have my effect created, but it doesn't seem to want to be in the right place, nor have the right angles.[/QUOTE]
[QUOTE=Ghost_Sailor;47453168][code]local v = self.Owner
local efct = EffectData()
efct:SetEntity(v)
efct:SetScale(.3)
efct:SetMagnitude(1)
local viewm = v:GetViewModel()
local muzzlepos = viewm:GetAttachment( 1 )
efct:SetOrigin(muzzlepos["Pos"])
efct:SetAngles(muzzlepos["Ang"])
efct:SetStart(muzzlepos["Pos"])
--util.Effect("TeslaZap",efct)
util.Effect("TeslaHitBoxes",efct)[/code][/QUOTE]
Still looking for help on this.
I can't get Entity:SetParentPhysNum to work and the wiki is wrong on the usage of it. Can anyone help? I'm just trying to parent a prop to a ragdoll bone.
Same for Entity:SetParent(Entity,Index). This doesn't work either. Should I open an issue on garrysmod-issues?
[editline]5th April 2015[/editline]
[QUOTE=Ghost_Sailor;47459685]Still looking for help on this.[/QUOTE]
efct:SetAttachment(1)
[QUOTE=Robotboy655;47459075]That's probably because you want to use multibyte characters as single byte, and that's where you fail.
Willox made a utf8 library for Lua, but I am not sure if he released it or not, you should ask him.[/QUOTE]
I am simply saving a translated string as a variable (often containing accents or other special characters i.e. Cyrillic or Chinese) and the special characters are not being retained. I dont't recall having used anything related to single or multi byte allocation. Would willox's library help in this instance?
Looking to implement a way to keep players out of no draw areas on maps to disallow players from getting there.
Trying to find a good balance between adding to server load and implementing an effective solution.
So far, we have looked at doing Killzones (preferably with a warning system) using the likes of using FindInBox but Ild expect constantly checking this would be pretty heavy processing wise.
Also looked at adding invisible walls, and using the PhysicsCollide To notify the player they have hit the wall, Making use of the Entity Callback.
Mainly looking for comments of performance or if there is a better way to achieve this.
I uploaded my SWEP to the workshop and the sounds are working (for me at least), a friend downloaded it to test it and this showed up
[code]Failed to load sound "sound\weapons\allu\allu_redbull.mp3", file probably missing from disk/repository
Create Stream Failed error 41[/code]
I put the mp3's in a sound file located AlluAWP/sound/weapons/allu.
Any reason why it isn't working for people who download it?
[B]Edit:[/B]
Problem solved, had to remove sound/ for it to work.
Is it possible to use SetMaterial("wood/infceilinga") on a clientside model? Using the material option in the SWEP construction kit does nothing and I can't get the material to change manually.
You could set a variable on the entity then override RenderOverride and render the material.
[QUOTE=BoboHobo;47459362]Having a problem when trying to convert the Combine Control swep base over to Nutscript 1.1.
I have tried and tried to get this to work, but no luck.
[CODE]
[ERROR] gamemodes/hl2rp/entities/weapons/weapon_cc_base/sh_helper.lua:180: bad argument #2 to 'LerpAngle' (Angle expected, got nil)
1. LerpAngle - [C]:-1
2. FreeaimThink - gamemodes/hl2rp/entities/weapons/weapon_cc_base/sh_helper.lua:180
3. unknown - gamemodes/hl2rp/entities/weapons/weapon_cc_base/shared.lua:389
[/CODE]
Happen's right when I try to equip my weapon.
[CODE]self.currentFreeAimOffset = LerpAngle(FrameTime() * 10, self.currentFreeAimOffset, self.freeAimOffset)[/CODE]
This is the line the error points me too. I am not that experienced in coding, so all of this is complicated to me, but any help is appreciated! There is various other errors, but I'll try and solve them one at a time.[/QUOTE]
[QUOTE=BoboHobo;47459385][CODE]--[[ freeaim ]]--
function SWEP:FreeaimThink()
local FT = FrameTime()
if SERVER then
-- freeaim stuff (serverside)
if self.useFreeaim then
if not self:InSights() then
local goalOffset, faLimit = self.freeAimOffset, self.freeAimLimit
local delta = self:GetAngularVelocity() * FT * self.freeAimSpeed
local length = (goalOffset.p - delta.p)^2 + (goalOffset.y - delta.y)^2
if length > (faLimit^2) then
local norm1, norm2 = goalOffset:Forward(), (goalOffset - delta):Forward()
local nAng = norm1:AngleEx(norm2) -- angle between the two points
-- we only care to take pitch and yaw
goalOffset.p = nAng.p
goalOffset.y = nAng.y
else
-- no need for fancy maths
goalOffset = goalOffset - delta
end
self.freeAimOffset = goalOffset
else
self.freeAimOffset = Angle(0, 0, 0)
end
end
else
-- freeaim stuff (clientside)
if self.useFreeaim then
if not self:InSights() then
local goalOffset, faLimit = self.freeAimOffset, self.freeAimLimit
local delta = self:GetAngularVelocity() * FT * self.freeAimSpeed
local length = (goalOffset.p - delta.p)^2 + (goalOffset.y - delta.y)^2
if length > (faLimit^2) then
local norm1, norm2 = goalOffset:Forward(), (goalOffset - delta):Forward()
local nAng = norm1:AngleEx(norm2) -- angle between the two points
-- we only care to take pitch and yaw
goalOffset.p = nAng.p
goalOffset.y = nAng.y
else
-- no need for fancy maths
goalOffset = goalOffset - delta
end
self.freeAimOffset = goalOffset
self.currentFreeAimOffset = LerpAngle(FrameTime() * 10, self.currentFreeAimOffset, self.freeAimOffset)
else
self.freeAimOffset = Angle(0, 0, 0)
self.currentFreeAimOffset = LerpAngle(FrameTime() * 10, self.currentFreeAimOffset, self.freeAimOffset)
end
if self.nextFreeAimSync <= CurTime() then -- keep it in sync, just to avoid rounding errors.
-- i realize im trusting the client, but it keeps it from being super jumpy and still keeps it in sync
net.Start("fa_sync_s")
net.WriteAngle(self.freeAimOffset)
net.SendToServer()
self.nextFreeAimSync = CurTime() + 1
end
end
end
end[/CODE]
here is the full code, if it helps, as I edited into my post, I am not THAT experienced, and am only editting this base to work over on Nutscript, so I'm not sure. This is probably a bit advanced for me, but I'm doing it just for the practice and experience.[/QUOTE]
Still need assistance.
hey guys, i ran into a problem.
So i got a database where i store an Angle, that angle is being seperated with a "," in the database so it'll be easy for me to take it out, and use string.Explode to take the x,y,z apart.
for some reason when i try to make the x,y,z an angle it prints out as 0,0,0.
This is my code:
[CODE]
for k,v in pairs(info) do
local tempang = string.Explode(",",v["angpos"])
print(tempang[1])
print(tempang[2])
print(tempang[3])
print(Angle(tempang[1],tempang[2],tempang[3]))
end
[/CODE]
The output is this:
[CODE]
-0.03125
-171.9375
0
0.000 0.000 0.000
[/CODE]
anyone has any idea why?
Which part is right and which part is wrong?
[QUOTE=G4MB!T;47463716]Which part is right and which part is wrong?[/QUOTE]
the first 3, are the x,y,z, and for some reason, when i combine them to an actuall Angle they come out as 0,0,0.
they are strings, try converting them to numbers
[code]
print(Angle(tonumber(tempang[1]),tonumber(tempang[2]),tonumber(tempang[3])))
[/code]
[QUOTE=Fantym420;47463833]they are strings, try converting them to numbers
[code]
print(Angle(tonumber(tempang[1]),tonumber(tempang[2]),tonumber(tempang[3])))
[/code][/QUOTE]
I LOVE YOU MAN!
Thanks haha
[quote=Author]Oh, and, I keep getting mod_studio: MOVETYPE_FOLLOW with no model error when in OBS_MODE_ROAMING. Is this an issue on my end? If so, how would I be able to fix it?[/quote]
Why isnt this working
[lua]
hook.Add("PlayerTick","CENSORED",function(ply,mv)
local speed
if ply:InVehicle() then
speed = ply:GetVehicle():GetVelocity():Length()
else
speed = ply:GetVelocity():Length()
end
//do stuff with speed
end
[/lua]
ply:GetVelocity():Length() works but when I enter a vehicle and print the speed it prints this instead:
[CODE]VehicleType:prop_vehicle_airboat:[/CODE]
depending on the vehicle
[editline]6th April 2015[/editline]
it actually doesn't print anything
not even newlines
[lua]MsgN(ply:GetVehicle())[/lua]
doesn't print or do anything
[editline]6th April 2015[/editline]
(when I'm not in a vehicle it prints NULL entity)
How can I hide the little scroll arrows on a RichText? I dont even need them and it shows it
Hello there,
I am trying to learn Lua scripting and decided to try to update a gamemode for gmod13.
But I've run into an error I just can't figure out. I keep getting this error:
[Lua]
Attempted to create unknown entity type lap_selector!
NULL Ent in GiveNamedItem!
Debug: Line 3152
[/Lua]
This is the function:
[Lua]
function WMSpawnCheck(ply)
if ply:IsValid() && !ply:HasWeapon("lap_selector") then
ply:Give("weapon_physgun")
ply:Give("lap_selector")
print("Debug: Line 3152")
ply:SelectWeapon("lap_selector")
ply:Give("gmod_camera")
ply:Give("gmod_tool")
timer.Simple(30, function() WMSpawnCheck(ply) end)
end
end
[/Lua]
For some reason the server seems to think the lap_selector entity is nonexistent.
The lap_selector entity is located in gamemodes/gamemode/entities/weapons/lap_selector
The folder contains two files.
cl_init.lua
[Lua]
include("shared.lua")
local keyevents = false
local keyevents2 = false
function SWEP:Initialize()
self.reloadtimer = 0
end
function SWEP:Think()
local ply = self:GetOwner()
if (!ply:KeyDown(IN_ATTACK)) && keyevents then
ply:ConCommand("-wmselect")
keyevents = false
end
if (!ply:KeyDown(IN_RELOAD)) && keyevents2 then
ply:ConCommand("-wmstanceradial")
keyevents2 = false
end
self.Weapon:NextThink(CurTime() + 0.05)
return true
end
function SWEP:Reload()
if IsFirstTimePredicted() then
if self.reloadtimer <= CurTime() then
self.reloadtimer = (CurTime() + 1)
else
return false
end
end
local ply = self:GetOwner()
if ply:KeyDown(IN_SPEED) || ply:KeyDown(IN_DUCK) || ply:KeyDown(IN_JUMP) || ply:KeyDown(IN_USE) || ply:KeyDown(IN_WALK) then
ply:ConCommand("wmstanceselect")
elseif keyevents2 == false then
keyevents2 = true
ply:ConCommand("+wmstanceradial")
end
end
function SWEP:PrimaryAttack()
keyevents = true
self:GetOwner():ConCommand("+wmselect")
end
function SWEP:SecondaryAttack()
self:GetOwner():ConCommand("wmorder")
self.Weapon:SetNextSecondaryFire( CurTime() + 0.5 )
end
function SWEP:Holster()
self:GetOwner():ConCommand("-wmselect")
return true
end
[/Lua]
shared.lua
[Lua]
if ( SERVER ) then
AddCSLuaFile ( "shared.lua" )
AddCSLuaFile ( "cl_init.lua" )
end
if ( CLIENT ) then
SWEP.PrintName = "Selector"
SWEP.Slot = 2
SWEP.SlotPos = 8
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = true
end
SWEP.ViewModelFOV = 60
SWEP.ViewModelFlip = false
SWEP.ViewModel = "models/weapons/v_357.mdl"
SWEP.WorldModel = "models/weapons/w_357.mdl"
SWEP.Spawnable = true
SWEP.AdminSpawnable = false
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = 0
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = ""
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = 0
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = ""
function SWEP:Deploy ( )
self.Weapon:SendWeaponAnim ( ACT_VM_DRAW )
return true
end
[/Lua]
The shared.lua file is also being added to the server download list.
[Lua]
AddCSLuaFile( "../entities/weapons/lap_selector/shared.lua" )
[/Lua]
Other places that references "lap_selector" if needed:
[Lua]
function PlayerCanPickupWeapon(ply, wep)
if wep:GetClass() ~= "gmod_tool" && wep:GetClass() ~= "gmod_camera" && wep:GetClass() ~= "lap_selector" && wep:GetClass() ~= "weapon_physgun" && !IsAdminOrSinglePlayer(ply) then
return false
end
end
[/Lua]
[Lua]
function PlayerCanGiveWeapon(ply, wep)
if wep ~= "gmod_tool" && wep ~= "lap_selector" && wep ~= "weapon_physgun" && !IsAdminOrSinglePlayer(ply) then
return false
end
end
[/Lua]
[Lua]
function WeaponEquip( wep )
if wep:GetClass() ~= "gmod_tool" && wep:GetClass() ~= "gmod_camera" && wep:GetClass() ~= "lap_selector" && wep:GetClass() ~= "weapon_physgun" then
wep:GetOwner():ConCommand("quit")
end
end
[/Lua]
[Lua]
function NoSuicide ( ply )
ply:Give("weapon_physgun")
ply:Give("lap_selector")
ply:SelectWeapon("lap_selector")
ply:Give("gmod_camera")
ply:Give("gmod_tool")
if !IsAdminOrSinglePlayer(ply) then
umsg.Start("WMSuicideSend",ply)
umsg.End()
return false
end
end
[/Lua]
[Lua]
function Loadout( ply )
ply:Give("weapon_physgun")
ply:Give("lap_selector")
ply:SelectWeapon("lap_selector")
ply:Give("gmod_camera")
ply:Give("gmod_tool")
return true
end
[/Lua]
[Lua]
function WMInitialJoin(ply)
timer.Simple(10, function() SendTime() end)
ply:ConCommand("wmhelp")
timer.Simple(2, function() ply:ConCommand("wmmenu") end)
timer.Simple(1, function() SendText(ply, VariantDescription) end)
for i = 1, 7 do
SendBounty(i, ply)
end
local message = game.GetMap()
ply.TeamInvitation = nil
ply:Spectate(0)
ply:UnSpectate()
ply:Give("weapon_physgun")
ply:Give("lap_selector")
ply:Give("gmod_camera")
ply:Give("gmod_tool")
timer.Simple(15, function() WMSpawnCheck(ply) end)
if FirstPlayer == 0 && ADSpawnFile ~= nil then
ply:Team(0)
AdvDupeTime(ply)
ply:Freeze(true)
return
end
[/Lua]
Any help is appreciated.
Thanks.
-Matias
Entities now don't have a folder for themselves,
in the weapons folder, remove the lap_selector folder and combine the two files into one, name it "lap_selector.lua"
[QUOTE=AnonTakesOver;47465244]Entities now don't have a folder for themselves,
in the weapons folder, remove the lap_selector folder and combine the two files into one, name it "lap_selector.lua"[/QUOTE]
Yea, I actually tried that too. That didn't work either ^^
I might've done it wrong.
I looked at the camera swep from the sandbox gamemode for clues as to how I should make the file.
Here's the combined file:
[Lua]
AddCSLuaFile()
SWEP.ViewModel = Model("models/weapons/v_357.mdl")
SWEP.WorldModel = Model("models/weapons/w_357.mdl")
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
SWEP.PrintName = "#Selector"
SWEP.Slot = 2
SWEP.SlotPos = 8
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = true
SWEP.Spawnable = false
SWEP.AdminSpawnable = false
if(CLIENT)
local keyevents = false
local keyevents2 = false
function SWEP:Initialize()
self.reloadtimer = 0
end
function SWEP:Think()
local ply = self:GetOwner()
if (!ply:KeyDown(IN_ATTACK)) && keyevents then
ply:ConCommand("-wmselect")
keyevents = false
end
if (!ply:KeyDown(IN_RELOAD)) && keyevents2 then
ply:ConCommand("-wmstanceradial")
keyevents2 = false
end
self.Weapon:NextThink(CurTime() + 0.05)
return true
end
function SWEP:Reload()
if IsFirstTimePredicted() then
if self.reloadtimer <= CurTime() then
self.reloadtimer = (CurTime() + 1)
else
return false
end
end
local ply = self:GetOwner()
if ply:KeyDown(IN_SPEED) || ply:KeyDown(IN_DUCK) || ply:KeyDown(IN_JUMP) || ply:KeyDown(IN_USE) || ply:KeyDown(IN_WALK) then
ply:ConCommand("wmstanceselect")
elseif keyevents2 == false then
keyevents2 = true
ply:ConCommand("+wmstanceradial")
end
end
function SWEP:PrimaryAttack()
keyevents = true
self:GetOwner():ConCommand("+wmselect")
end
function SWEP:SecondaryAttack()
self:GetOwner():ConCommand("wmorder")
self.Weapon:SetNextSecondaryFire( CurTime() + 0.5 )
end
function SWEP:Holster()
self:GetOwner():ConCommand("-wmselect")
return true
end
function SWEP:Deploy ( )
self.Weapon:SendWeaponAnim ( ACT_VM_DRAW )
return true
end
end
[/Lua]
[QUOTE=Exho;47464899]How can I hide the little scroll arrows on a RichText? I dont even need them and it shows it[/QUOTE]
[url]http://wiki.garrysmod.com/page/Panel/SetVerticalScrollbarEnabled[/url]
This hides them.
This is kinda a silly question but is it possible, at all, for a player model to kill and spawn players in locations they shouldn't normally spawn in? I have a model in my TTT server and players with them are instantly dying once they spawn in, but not all of the time. I'm not really sure how to debug this and I didn't think it was remotely possible for a model to cause that, but I've witnessed it. Might also add that while using the TTT Damage logs addon by tommy, they're apparently dying by unknown/world. :P
I'm having problems with precached sounds in a SWEP. I have this code here;
[lua]
local shootSound = Sound( "Weapon_Crossbow.Single" )
function SWEP:PrimaryAttack()
if SERVER then
self.EmitSound( shootSound )
end
end
[/lua]
But whenever I fire the weapon, it gives an error saying it tried to use a null entity. Why is that?
[editline]6th April 2015[/editline]
Nevermind, I just had to do self.Owner:EmitSound().
even though you fixed it, the problem was because you used a dot instead of a colon
a colon automatically passes the object you're calling the function on as the first argument to the function
Sorry, you need to Log In to post a reply to this thread.