Technology (Read Only) > Programming
Multiple Scripting Problems
StartedBullet:
Hello, I'm having trouble running console commands for my gamemode, here is what im talking about:
gamemodes\laststand\gamemode\init.lua:25: '=' expected near 'player'-init
--player:concommand( "PlayerInitialGear" )
_______________
gamemodes\laststand\gamemode\cl_init.lua:21: 'then' expected near 'player'
-cl_init
--player:ConCommand( "sb_team1" )
________________
Any ideas on what I am doing wrong?/ Do you know any other ways i can run a console command?
Thats solved. But heres another problem: It considers 'ready' invalid somehow and won't paint my vgui-function HumanBuy( ply )
ready = vgui.Create( "BFrame" )
ready:SetPos( ScrW() / 2, ScrH() / 2 ) //Set the position. Half the screen height and half the screen width. This will result in being bottom right of the middle of the screen.
ready:SetSize( 175, 175 ) //The size, in pixels of the Frame
ready:SetTitle( "Select Items/Upgrades" )
ready:SetVisible( true )
ready:SetDraggable( true )
ready:ShowCloseButton( true )
ready:MakePopup()
ready1 = vgui.Create( "BButtonSMG1", Ready ) // Define ready1 as a "DButton" with its parent the Ready frame we just created above.
ready1:SetPos( 20, 160 ) //Set position, relative to the frame (If you didn't parent it, it would be relative to the screen
ready1:SetSize( 140, 40 ) // How big it should be, again in pixels
ready1:SetText( "Buy SMG1-5" )
ready1.DoClick = function() //ready1.doclick = function, we just defined it as a function
ply:Give( "weapon_SMG1" )
Player:GiveAmmo(25,"smg1")
ply:SetNWInt("killcounter", ply:GetNWInt("killcounter") - 5)
end
ready2 = vgui.Create( "BButtonSMG1Ammo", Ready ) // Define ready1 as a "DButton" with its parent the Ready frame we just created above.
ready2:SetPos( 170, 160 ) //Set position, relative to the frame (If you didn't parent it, it would be relative to the screen
ready2:SetSize( 140, 40 ) // How big it should be, again in pixels
ready2:SetText( "Buy SMG1 Ammo-2" )
ready2.DoClick = function() //ready1.doclick = function, we just defined it as a function
Player:GiveAmmo(15,"smg1")
ply:SetNWInt("killcounter", ply:GetNWInt("killcounter") - 2)
end
ready3 = vgui.Create( "BButtonShotgun", Ready ) // Define ready1 as a "DButton" with its parent the Ready frame we just created above.
ready3:SetPos( 20, 120 ) //Set position, relative to the frame (If you didn't parent it, it would be relative to the screen
ready3:SetSize( 140, 40 ) // How big it should be, again in pixels
ready3:SetText( "Buy Shotgun-10" )
ready3.DoClick = function() //ready1.doclick = function, we just defined it as a function
ply:Give( "weapon_Shotgun" )
Player:GiveAmmo(10,"buckshot")
ply:SetNWInt("killcounter", ply:GetNWInt("killcounter") - 10)
end
ready4 = vgui.Create( "BButtonShotgunAmmo", Ready ) // Define ready1 as a "DButton" with its parent the Ready frame we just created above.
ready4:SetPos( 170, 120 ) //Set position, relative to the frame (If you didn't parent it, it would be relative to the screen
ready4:SetSize( 140, 40 ) // How big it should be, again in pixels
ready4:SetText( "Buy Shotgun Ammo-4" )
ready4.DoClick = function() //ready1.doclick = function, we just defined it as a function
Player:GiveAmmo(8,"buckshot")
ply:SetNWInt("killcounter", ply:GetNWInt("killcounter") - 4)
end
end
Then theres my last post aswell. But im extremely close to finishing my gamemode (first).
Tomcat:
you need to do LocalPlayer:ConCommand()
Кrаsher:
--- Quote from: Tomcat on September 05, 2010, 07:42:27 PM ---you need to do LocalPlayer:ConCommand()
--- End quote ---
that is deprecated bro
since I know what tut you are getting this from...
put that in GM:PlayerInitialSpawn( ply )
as RunConsoleCommand("sb_team1")
Rbn:
--- Quote from: StartedBullet on September 05, 2010, 07:01:32 PM ---Hello, I'm having trouble running console commands for my gamemode, here is what im talking about:
gamemodes\laststand\gamemode\init.lua:25: '=' expected near 'player'-init
--player:concommand( "PlayerInitialGear" )
_______________
gamemodes\laststand\gamemode\cl_init.lua:21: 'then' expected near 'player'
-cl_init
--player:ConCommand( "sb_team1" )
________________
Any ideas on what I am doing wrong?/ Do you know any other ways i can run a console command?
--- End quote ---
Let's see...
- If your working on a clientside script to set player on a custom team, need to be triggered somehow like a button or something, you can do other things but
i do not really recommend it on client :/, unless you want to make the player select team.
- Кrашер GM:PlayerInitialSpawn( ply ) is serverside only so RunConsoleCommand Will affect console not the player.
--- Code: ---function GM:PlayerInitialSpawn( ply )
ply:ConCommand("sb_team1") -- notice that server will trigger it only on the 1stly spawn.
end
--- End code ---
naturally sb_team1 command will be like.
--- Code: ---concommand.Add("sb_team1", function( p,c,a ) p:SetTeam("TEAM_NAME" [[ or #index of team ]]) end )
--- End code ---
But if you want to work over performance and efficiency, DEPENDING ON WHAT YOU ARE DOING.
I recommend using like this.
--- Code: ---function GM:PlayerInitialSpawn( ply )
ply:SetTeam( "TEAM_NAME" [[ or #index of team ]] ) -- This will make that server set player on the specified team and do not need to trigger command on client.
end
--- End code ---
On wiki when they put "player", this mean that you need the Player Entity, not to put it as they write, like first Entities on a 16 / 16 server are related to player entity slots so will be like
Entity(1):Nick() -- Return Nick of the player that Have in the Entity index #1.
Entity(1) = Whole Class Entity of a player, Nick() method to obtain the name or nick.
Check an example or trying to do an example lol.
--- Code: ---function SetPlayerOnTeam( playerobtained )
playerobtained:SetTeam(1)
end
SetPlayerOnTeam( Entity(1) ) -- i sent the player's entity as an argument, then the function make the rest of the work.
--- End code ---
ClientSide = RunConsoleCommand( STRING )
ServerSide = PLAYER:ConCommand( STRING )
PLAYER = Entity of the player as explained before.
Hope that will be helpful for you.
StartedBullet:
Thank you this seems to have solved it, but I have seem to have another (hopefully last bug):
gamemodes\laststand\gamemode\init.lua:126: bad argument #1 to 'random' (interval is empty)
Heres the code snippet:
function GMZombieSpawn( tr )
local spawns = ents.FindByClass( "Zombie_Spawn_Point" )
local RandomSpawn = math.random(#spawns) <---- 126
local ent = ents.Create( "npc_zombie" )
ent:SetPos( tr.HitPos )
ent:Spawn( RandomSpawn )
ent:Activate()
end
Any ideas? Also, what would be a good way to put a cap on how many zombies spawn?
Navigation
[0] Message Index
[#] Next page
Go to full version