Well, but it's a lot nicer than adding this code to every hook
[lua]
hook.Add("PlayerSpawn", "playerpawn", function(ply)
local team = ply:Team()
if(team == TEAM_CITIZEN) then
-- do stuff
elseif(team == TEAM_MAYOR) then
-- do stuff
end
end)
[/lua]
Are you saying it's nicer to add 10 hooks than it is 1?
It's certainly cleaner.
It's redundant.
What's so redundant about that?
It's pretty much the same as the [URL="http://svn.facepunchstudios.com/svn/gm/garrysmod/gamemodes/sandbox/gamemode/player_class/player_sandbox.lua"]player classes[/URL] garry introduced in the beta
[QUOTE=FPtje;38205713]Currently I'm just thinking the way thelastpenguin said it. Should do it, right?
Well without the different function name that is[/QUOTE]
I'm very glad you've decided to implement this :) It does make classes much easier to read / general structure.
If its ok, I'd really appreciate some form of recognition for the idea such as a comment in the file or you're choice really.
[QUOTE=Lexic;] Look at how much more verbose the new surface.CreateFont calls are.[/QUOTE]
that was actually one of my major inspirations for making this for my self, and eventually suggesting it here.
If you don't add callbacks to the team definitions then anyone who wants to do something slightly more complex such as give the police 20 smg ammo or spawn a hat entity on the mayor has to go edit the gamemode files. Tiny edits admittedly, but they all add up and eventually you end up with incompatible offshoots like the one I'm maintaining.
I have a strange problem after I installed gmod thru hldsupdatetool with srcds , then i try to install cs:s content too and it says,
This game conflicts with the games already installed in that directory.
Please pick a new location.
i use -dir c:\srcds
so should I use c:\srcds\orangebox for cs:s?
[QUOTE=Lexic;38206007]Might as well go all the way into the land of readability with the names, eh?
[lua]Shipment "Bananas" {
Model = "models/props/cs_italy/bananna.mdl";
Class = "auto_remove"
Price = 10;
Amount = 10;
AvailableSeperately = false;
SeperatePrice = 0;
SeperateOnly = false;
Teams = {-1};
SeperateTeams = {-1};
SeperateOnly = false;
-- Optional callback to be called when the player presses 'e' on the spawned_weapon instead of ply:Give(shipment.Class).
function(ply, shipment_info, shipment_ent)
ply:ChatPrint("BANANAS!");
-- Return true to delete the spawned_weapon, false to leave it as it is.
return true;
end
};[/lua][/QUOTE]
Cant you only do 1 argument if you were going to drop the parentheses, not two?
[QUOTE=zzaacckk;38220727]Cant you only do 1 argument if you were going to drop the parentheses, not two?[/QUOTE]
I use the magical power of return closures.
[editline]28th October 2012[/editline]
[code]Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> function doprint(msg)
>> return function(msg2) print(msg .. " " .. msg2) end
>> end
> doprint "Hello" "world!"
Hello world![/code]
Just a thought about the whole convars and toggalable features discussed like 2 pages ago. Why don't you remove the majority of these toggalable features apart from ones with more than 2 values (true and false like the max doors toggle which has between like 1 and 10).
Once you have eliminated them in-game you can just have them as commands in a file somewhere where all you need is pretty much no coding knowledge to open the file with the settings in, find the comment about that command then set it from true to false and vice versa.
---
As for the new structure of jobs and entities etc, is this a necessary change that we should make for our DarkRP files? Also it'd be nice as said to clean up the shared.lua so that you can place jobs in an order that they will appear on the F4 menu that won't apparently break the code.
Also an error I am having is that I have coded 7 custom jobs + hobo = 8 Custom jobs, And it seems that they break the F4 menu and it all appears in the top left corner and in its place a blank menu appears in the centre. Any idea's on how to fix this?
EDIT:
It seems the F4 menu can only hold 12 jobs in it and after that it should create a scroll bar to fit in the extra jobs but it doesn't which causes it to bug up. Any idea's on how to fix this other than editing the derma?
[QUOTE=Lexic;38220964]I use the magical power of return closures.
[editline]28th October 2012[/editline]
[code]Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> function doprint(msg)
>> return function(msg2) print(msg .. " " .. msg2) end
>> end
> doprint "Hello" "world!"
Hello world![/code][/QUOTE]
you should learn Haskell. You'll love it.
All I see these days are Darkrp servers and the occasional city rp servers (the latter being the most decent when mods and admins are around). I miss the good old fashioned Melonbrew-esque HL2 rp's that take their shit seriously with regular rations handed out to citizens every now and then instead of this "salary" bullcrap coming out of nowhere. Oh, and actually mean metrocops faithful to the HL2 universe without some asshat crying "OMG POLICE ABUSE" everytime they get beaten the shit out of them for the slightest resistance.
God, I miss Melonbrew.
[QUOTE=Lexic;38219076]If you don't add callbacks to the team definitions then anyone who wants to do something slightly more complex such as give the police 20 smg ammo or spawn a hat entity on the mayor has to go edit the gamemode files. Tiny edits admittedly, but they all add up and eventually you end up with incompatible offshoots like the one I'm maintaining.[/QUOTE]
That's a very good argument.
These functions can now be defined in a team table:
[lua]CanPlayerSuicide(ply)
PlayerCanPickupWeapon(ply, weapon)
PlayerChangeTeam(ply, oldTeam, newTeam)
PlayerDeath(ply)
PlayerDisconnected(ply)
PlayerLoadout(ply)
PlayerSelectSpawn(ply, spawn)
PlayerSetModel(ply)
PlayerSpawn(ply)
PlayerSpawnProp(ply, model)
ShowSpare1(ply)
ShowSpare2(ply)[/lua]
Example:
[lua]
TEAM_CITIZEN = AddExtraTeam("Citizen", {
color = Color(20, 150, 20, 255),
model = {
"models/player/Group01/Female_01.mdl",
"models/player/Group01/Female_02.mdl",
"models/player/Group01/Female_03.mdl",
"models/player/Group01/Female_04.mdl",
"models/player/Group01/Female_06.mdl",
"models/player/Group01/Female_07.mdl",
"models/player/group01/male_01.mdl",
"models/player/Group01/Male_02.mdl",
"models/player/Group01/male_03.mdl",
"models/player/Group01/Male_04.mdl",
"models/player/Group01/Male_05.mdl",
"models/player/Group01/Male_06.mdl",
"models/player/Group01/Male_07.mdl",
"models/player/Group01/Male_08.mdl",
"models/player/Group01/Male_09.mdl"
},
description = [[The Citizen is the most basic level of society you can hold
besides being a hobo.
You have no specific role in city life.]],
weapons = {},
command = "citizen",
max = 0,
salary = 45,
admin = 0,
vote = false,
hasLicense = false,
-- The example part of the example:
PlayerChangeTeam = function(ply, oldTeam, newTeam)
if oldTeam == TEAM_MAYOR then
GAMEMODE:Notify(ply, 1, 4, "I couldn't think of a better example, OK?")
return false
end
end
})[/lua]
I dunno how relevant PlayerSpawnProp will be but neat.
disallow if they aren't a certain class?
[editline]29th October 2012[/editline]
ie. making a builder class
[QUOTE=Banana Lord.;38234477]disallow if they aren't a certain class?
[editline]29th October 2012[/editline]
ie. making a builder class[/QUOTE]
I think in that particular case a conventional hook would make far more sense but whatever.
[QUOTE=Lexic;38234611]I think in that particular case a conventional hook would make far more sense but whatever.[/QUOTE]
I would think that is better in any of these cases too but whatever
[QUOTE=Banana Lord.;38234939]I would think that is better in any of these cases too but whatever[/QUOTE]
It doesn't hurt anyone just being there. The old syntax is still compatible.
[QUOTE=Banana Lord.;38234939]I would think that is better in any of these cases too but whatever[/QUOTE]
Then no offense, but I don't think you can have a particularly firm grasp on the concept of modularity.
If a gamemode is going to perform actions based on the activities of a certain class, those actions should be (if possible) defined in the same place as the concept of that class.
For instance, cancelling the lockdown when the mayor steps down has absolutely no place in the ply:ChangeTeam() function. It's a hard-coded specific action nailed into a generalised function and really should be triggered in the Mayor class specification. That way if the concept of mayors or lockdowns needs to change the code can be instantly found and adjusted/removed.
Is there a semi-stable version of DarkRP? I am having tons of problems with mine and it is updated to the most recent version. I made a thread for all the problems I have been encountering. It includes this list:
[QUOTE]
1. Can't give players money.
2. Players respawn as a ghost and cannot take damage.
3. Can't buy/disallow ownership/edit groups of doors.
4. Shipments do not work. You can't destroy them or get items from them.
5. Prop removed due to spam. You can't spawn any props.
6. F4 menu has purple/black texture.
[/QUOTE]
I've been using the most recent version of darkrp and im getting some errors with money not spawning with /dropmoney and moneyprinters stop spawning money. I think I've managed to trace it back to garry's timer system basicly not working. From what I can tell it appears that theres an error in darkrp or somewere else in gmod that ( when triggered, i havnt been able to figure out what it is ) breaks the timer system.
Im not sure if anyone knows anything about this, but I wanted to put the problem out there as something that maby should be looked at. There's not much to go on unfortunately. I've been reading over logs for hours and havn't found a thing.
[EDIT]
I'm attempting to fix this by adding a pcall to the timer system. Though it's a bit messy, it should let me confirm if it is the source of the error.
I would really like a good working version of DarkRP. It seems like the GMod 13 beta version is better than the most recent one. How could I download it?
Hay FPtje, since the Camera modell changed in gmod 13 you should do something about /call function couse i see purle textures on the old mobile phone modell from gmod 12
[QUOTE=FPtje;38234026]That's a very good argument.
These functions can now be defined in a team table:
[lua]CanPlayerSuicide(ply)
PlayerCanPickupWeapon(ply, weapon)
PlayerChangeTeam(ply, oldTeam, newTeam)
PlayerDeath(ply)
PlayerDisconnected(ply)
PlayerLoadout(ply)
PlayerSelectSpawn(ply, spawn)
PlayerSetModel(ply)
PlayerSpawn(ply)
PlayerSpawnProp(ply, model)
ShowSpare1(ply)
ShowSpare2(ply)[/lua]
[/QUOTE]
Rather than specifying for users what functions they can / cant set, it'd be nicer if you would provide a function where users can specify a hook they wish to use aswell as a corresponding property in the table. That way it would be much more general purpose and a more useful feature.
[QUOTE=Lexic;38237162]Then no offense, but I don't think you can have a particularly firm grasp on the concept of modularity.
If a gamemode is going to perform actions based on the activities of a certain class, those actions should be (if possible) defined in the same place as the concept of that class.
For instance, cancelling the lockdown when the mayor steps down has absolutely no place in the ply:ChangeTeam() function. It's a hard-coded specific action nailed into a generalised function and really should be triggered in the Mayor class specification. That way if the concept of mayors or lockdowns needs to change the code can be instantly found and adjusted/removed.[/QUOTE]
I agree, but I fear that editing shared.lua too often will piss people off.
It's not like they have another option or something. They can backup their stuff and paste it in again, I see no trouble with that.
[QUOTE=FPtje;38251776]I agree, but I fear that editing shared.lua too often will piss people off.[/QUOTE]
Move the team definitions to a different file then. AddExtraTeams or something.
[editline]30th October 2012[/editline]
(Also have AddNormalTeams for the built in classes so you can edit them)
What I meant by rp_dm_autokick not working is that setting it to 0 doesn't seem to disable it.
Sorry, you need to Log In to post a reply to this thread.