Hi all, I need a little help because I don't understand this issue.
When I launch my script with "[U]lua_openscript_cl dermawelcome.lua[/U]" it's totaly work.
[U]Clientside: garrysmod\lua\dermawelcome.lua[/U]
[CODE]local ContinueButton = vgui.Create("DButton", Frame) --Bouton "Continuer"
ContinueButton:SetSize(120, 30)
ContinueButton:SetPos(250, 350)
ContinueButton:SetText("Continuer")
ContinueButton.DoClick = function(ply)
DarkRP.setPreferredJobModel(TEAM_SURVIVOR, SpawnModel[modelCounterSpawn]) --Alternative to setmodel not permanent...
LocalPlayer():ConCommand( "say /survivor" )
LocalPlayer():ConCommand( "_senddarkrpvars" )
Frame:Remove()
OpenWeaponMenu()
end[/CODE]
Then when I use
[U]
Serverside: addons\wm_spawn\lua\autorun\server\sv_spawn_menu.lua[/U]
[CODE]util.AddNetworkString("CharacterSpawnUDRP")
hook.Add("PlayerInitialSpawn", "CharacterSpawnUDRP", function(pl)
net.Start("CharacterSpawnUDRP")
net.Send(pl)
end)[/CODE]
+
[U]Clientside: addons\wm_spawn\lua\autorun\client\cl_spawn_menu.lua[/U]
[CODE]net.Receive("CharacterSpawnUDRP",function(len)[/CODE]
my playermodel are random. Someone can help me ?
In fact, I try make a Derma who start at PlayerInitialSpawn for select the model, weapon, rp name...
When I use
[CODE]LocalPlayer():setmodel( SpawnModel[modelCounterSpawn] )[/CODE] the models stay just 4-5 seconds.
Please help me I become totaly crazy xD
Sorry for my focking bad English...
[B]PS:[/B] I'm new in lua
The player isn't known to the client yet in PlayerInitialSpawn; run a timer in that hook for 1 second as to not run into the gamemode overriding you, then run SetModel (no networking needed).
[QUOTE=code_gs;51940494]The player isn't known to the client yet in PlayerInitialSpawn; run a timer in that hook for 1 second as to not run into the gamemode overriding you, then run SetModel (no networking needed).[/QUOTE]
Big thank you for your response. I'm going to try. <3
[QUOTE=code_gs;51940494]The player isn't known to the client yet in PlayerInitialSpawn; run a timer in that hook for 1 second as to not run into the gamemode overriding you, then run SetModel (no networking needed).[/QUOTE]
Hey bro ! I'm totaly lost. Do you can give me an exemple ?
[QUOTE=MpLL71;51942401]Hey bro ! I'm totaly lost. Do you can give me an exemple ?[/QUOTE]
[url]https://wiki.garrysmod.com/page/timer/Simple[/url]
[QUOTE=code_gs;51942855][url]https://wiki.garrysmod.com/page/timer/Simple[/url][/QUOTE]
Yep i know this, but when I put this it isnt work :(
How are you putting it? Can we see the code?
Geferon: Sure !
cl_spawn_menu.lua
[CODE]
SpawnModel = {
"models/humans/modern/female_01.mdl",
"models/humans/modern/female_02.mdl",
"models/humans/modern/female_03.mdl",
"models/humans/modern/female_04.mdl",
"models/humans/modern/female_06.mdl",
"models/humans/modern/female_07.mdl",
}
surface.CreateFont( "defaultf1", {
font = "Akbar",
extended = true,
size = 35,
weight = 450,
blursize = 0,
scanlines = 0,
antialias = true,
})
net.Receive("CharacterSpawnUDRP",function(len)
local Frame = vgui.Create("DFrame") --DERMA Tab
Frame:SetSize(600, 400)
Frame:SetTitle( "Bienvenue sur Eventful-Destiny UnDead RôlePlay: Choisissez votre apparence physique." )
Frame:SetBackgroundBlur( true )
Frame:ShowCloseButton( true )
Frame:SetDraggable( false )
Frame:SetVisible( true )
Frame:Center( true )
Frame:MakePopup()
local DModelSpawn = vgui.Create( "DModelPanel", Frame ) --MODELS Tab
DModelSpawn:SetSize(400, 400)
DModelSpawn:SetPos(100, -40)
function DModelSpawn:LayoutEntity( Entity ) return end
DModelSpawn:SetModel(SpawnModel[1])
local modelCounterSpawn = 1
local PreviousModelButton = vgui.Create("DButton", Frame) --Bouton "précendent"
PreviousModelButton:SetSize(80, 30)
PreviousModelButton:SetPos(50, 175)
PreviousModelButton:SetText("Précedent")
PreviousModelButton:SetTextColor(color_black)
PreviousModelButton.DoClick = function()
modelCounterSpawn = modelCounterSpawn - 1
if modelCounterSpawn == -1 or modelCounterSpawn == 0 or modelCounterSpawn == 6 then
modelCounterSpawn = table.Count(SpawnModel)
end
DModelSpawn:SetModel( SpawnModel[modelCounterSpawn] )
end
local NextModelButton = vgui.Create("DButton", Frame) --Bouton "suivant"
NextModelButton:SetSize(80, 30)
NextModelButton:SetPos(450, 175)
NextModelButton:SetText("Suivants")
NextModelButton:SetTextColor(color_black)
NextModelButton.DoClick = function()
modelCounterSpawn = modelCounterSpawn + 1
if modelCounterSpawn >= 6 then
modelCounterSpawn = 1
end
DModelSpawn:SetModel( SpawnModel[modelCounterSpawn] )
end
local ContinueButton = vgui.Create("DButton", Frame) --Bouton "Continuer"
ContinueButton:SetSize(120, 30)
ContinueButton:SetPos(250, 350)
ContinueButton:SetText("Continuer")
ContinueButton.DoClick = function()
LocalPlayer():SetModel( SpawnModel[modelCounterSpawn] )
Frame:Remove()
OpenWeaponMenu()
end
end )
[/CODE]
sv_spawn_menu.lua
[CODE]util.AddNetworkString("CharacterSpawnUDRP")
hook.Add("PlayerInitialSpawn", "sdqsdqsd", function(pl)
net.Start("CharacterSpawnUDRP")
net.Send(pl)
end )[/CODE]
I try place it in hook or in function Do.Click
Don't forget, I'm new in lua, so this code isn't perfect/good^^
I dont see timer.Simple anywhere in your code.
I try here [CODE]util.AddNetworkString("CharacterSpawnUDRP")
hook.Add("PlayerInitialSpawn", "sdqsdqsd", function(pl)
net.Start("CharacterSpawnUDRP")
net.Send(pl)
timer.Simple( 1, function() LocalPlayer():SetModel( SpawnModel[modelCounterSpawn] ) end )
end )[/CODE]
Oh, i understand whats going on now. So, basically you're changing the playermodel clientside, which will most likely reset right after you do it because of the server, as it is overriding it. You should network it to set the model on the serverside.
[QUOTE=geferon;51952801]Oh, i understand whats going on now. So, basically you're changing the playermodel clientside, which will most likely reset right after you do it because of the server, as it is overriding it. You should network it to set the model on the serverside.[/QUOTE]
It exactly this !!! But I'm a newbie in lua.
I was try use:
Client:
[CODE]ContinueButton.DoClick = function()
net.Start("MessageName")
net.WriteString( "" )
net.SendToServer()[/CODE]
SERVER:
[CODE]util.AddNetworkString( "MessageName" )
bla bla bla bla[/CODE]
But it's don't work too. I become crazy, 2 days on this xD
You forgot to add [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/net/Receive]net.Receive[/url]
[QUOTE=geferon;51952932]You forgot to add [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/net/Receive]net.Receive[/url][/QUOTE]
It was an exemple
[CODE]ContinueButton.DoClick = function()
net.Start("ChangeModelS")
net.WriteString( "" )
net.SendToServer()
Frame:Remove()
OpenWeaponMenu()
end[/CODE]
[CODE]util.AddNetworkString( "ChangeModelS" )
net.Receive( "ChangeModelS", function( len, ply )
ply:SetModel( SpawnModel[modelCounterSpawn] )
end )[/CODE]
[QUOTE][ERROR] addons/wm_spawn/lua/autorun/server/sv_spawn_menu.lua:11: attempt to index global 'SpawnModel' (a nil value)
1. func - addons/wm_spawn/lua/autorun/server/sv_spawn_menu.lua:11
2. unknown - lua/includes/extensions/net.lua:32
loaded
[/QUOTE]
The SpawnModel table doesn't exist.
[QUOTE=code_gs;51953157]The SpawnModel table doesn't exist.[/QUOTE]
And what is this ?
[CODE]SpawnModel = {
"models/humans/modern/female_01.mdl",
"models/humans/modern/female_02.mdl",
"models/humans/modern/female_03.mdl",
"models/humans/modern/female_04.mdl",
"models/humans/modern/female_06.mdl",
"models/humans/modern/female_07.mdl",
}[/CODE]
Try explain me plz !
Is that defined clientside or serverside?
[QUOTE=MpLL71;51953176]And what is this ?
[CODE]SpawnModel = {
"models/humans/modern/female_01.mdl",
"models/humans/modern/female_02.mdl",
"models/humans/modern/female_03.mdl",
"models/humans/modern/female_04.mdl",
"models/humans/modern/female_06.mdl",
"models/humans/modern/female_07.mdl",
}[/CODE]
Try explain me plz ![/QUOTE]
You created it on the clientsids file, not on the server side one
[editline]13th March 2017[/editline]
And also the modelCounterSpawn variable isnt defined as well
[editline]13th March 2017[/editline]
Ninja'd
[QUOTE=code_gs;51953280]Is that defined clientside or serverside?[/QUOTE]
Clientside
[editline]13th March 2017[/editline]
[QUOTE=geferon;51953281]You created it on the clientsids file, not on the server side one
[editline]13th March 2017[/editline]
And also the modelCounterSpawn variable isnt defined as well
[editline]13th March 2017[/editline]
Ninja'd[/QUOTE]
So I need create this for serverside too ? Or networked ?
[QUOTE=MpLL71;51953297]Clientside
[editline]13th March 2017[/editline]
So I need create this for serverside too ? Or networked ?[/QUOTE]
It's a static table so you can just define it shared. Networking isn't necessary.
[QUOTE=code_gs;51953309]It's a static table so you can just define it shared. Networking isn't necessary.[/QUOTE]
I need to use: [url]https://wiki.garrysmod.com/page/util/SharedRandom[/url] , util.SharedRandom ?
@geferon disagree :( . I say I'm a newbie in GLua (2 weeks on garry's mod). I try make it for pleasure and I want share it on the Workshop like [URL="http://steamcommunity.com/profiles/76561197967376528/myworkshopfiles/"]this[/URL].
[QUOTE=MpLL71;51953332]I need to use: [url]https://wiki.garrysmod.com/page/util/SharedRandom[/url] , util.SharedRandom ?
@geferon disagree :( . I say I'm a newbie in GLua (2 weeks on garry's mod). I try make it for pleasure and I want share it on the Workshop like [URL="http://steamcommunity.com/profiles/76561197967376528/myworkshopfiles/"]this[/URL].[/QUOTE]
SharedRandom is for predicted random instances. You can just use math.random(1, #SpawnModel).
Sorry, you need to Log In to post a reply to this thread.