• Simple Help Needed :D
    7 replies, posted
Hello everyone, so a friend of mine is re-editing an old gamemode and he's a bit confused on some parts. We already have a level system down, and different jobs you can pick. (It's not roleplay, it's a campaign (Get to this point, like left4dead.) gamemode. In the init.lua file, we have: [code] local job = Jobs[ply:GetNetworkedInt("job")] [/code] In our shared, this is where the jobs are customized: [code] Jobs[1] = {JNAME = "Shotgunner", USE_WEPGROUP = 1, PLAYERMODEL= "models/player/Group03/Female_02.mdl",} Jobs[2] = {JNAME = "Rifleman", USE_WEPGROUP = 2, PLAYERMODEL = "models/player/Group03/male_08.mdl"} [/code] So we have our level system by experience points, we got around 100 levels, intact. We need help making it so that if a player is not a certain level, they will get a message you "Cannot use that Job" and it will use the default job. Our CheckLevel function is for example: [code] if ply:CheckLevel() >= 2 then //If the player is a higher level than 2 then do whatever [/code] Here is a forced function for a user to use this job: [code] self:SetNetworkedInt( "job", 1) [/code] Can anyone come up with a code for something similar to this?: [code] if playerchose [Job[2]] then if ply:CheckLevel() >=15 then self:SetNetworkedInt( "job", 2) else message("You are not high enough level for this job.") self:SetNetworkedInt("job", 1) // Change to job 1 which is default. [/code] Thank you in advance :D
uhm i made this in notepad. i dont know if its any good or not. [lua] local level = { 10, 20, 30, 40 } -- Choose what lvl the diffrent jobs need local selectedJob = 3 --Id of the job theyr trying to use a number like 2,3,4 if playerchose [Job[level[selectedJob]]] and ply:CheckLevel() >= level[selectedJob] then self:SetNetworkedInt( "job", selectedJob ) else message("You need level " .. level[selectedJob] .. " or higher to have this job" self:SetNetworkedInt("job", 1) end[/lua]
[QUOTE=carlanton593;28694108]uhm i made this in notepad. i dont know if its any good or not. [lua] local level = { 10, 20, 30, 40 } -- Choose what lvl the diffrent jobs need local selectedJob = 3 --Id of the job theyr trying to use a number like 2,3,4 if playerchose [Job[level[selectedJob]]] and ply:CheckLevel() >= level[selectedJob] then self:SetNetworkedInt( "job", selectedJob ) else message("You need level " .. level[selectedJob] .. " or higher to have this job" self:SetNetworkedInt("job", 1) end[/lua][/QUOTE] I don't have a playerchose command xD
okei xD will this work though? i was thinking you could have this inside some function that changes job. and the function inputs the index for the job [lua] function changejob( ply, args ) local level = { 10, 20, 30, 40 } -- Choose what lvl the diffrent jobs need local selectedJob = tonumber(args[1]) --Id of the job theyr trying to use a number like 2,3,4 if ply:CheckLevel() >= level[selectedJob] then self:SetNetworkedInt( "job", selectedJob ) else message("You need level " .. level[selectedJob] .. " or higher to have this job" self:SetNetworkedInt("job", 1) end end concommand.Add("change_job",changejob) [/lua] and you could use this from a derma menu [lua] local JobButton1 = DermaMenu() JobButton1:AddOption("Yes.", function() RunConsoleCommand( "change_job", "2" ) JobMenu:Close() end ) JobButton1:AddOption("No.", function() end ) JobButton1:Open() end [/lua] please lat me know if this was helpfull:P
I already have a menu for choosing jobs already and such D: Anyways, would this code work? [code] if job = [2] then if ply:CheckLevel() >=15 then self:SetNetworkedInt( "job", 2) else message("You are not high enough level for this job.") self:SetNetworkedInt( "job", 1) end [/code]
change the first line there to: if job == 2 then and change both "self"s to ply [editline]21st March 2011[/editline] Oh and change the message("whatever") to ply:ChatPrint("whatever")
[QUOTE=moof;28690727] In our shared, this is where the jobs are customized: [code] Jobs[1] = {JNAME = "Shotgunner", USE_WEPGROUP = 1, PLAYERMODEL= "models/player/Group03/Female_02.mdl",} [/QUOTE] Comma at the end of that line isn't supposed to be there
[QUOTE=Andriko1;28742599]Comma at the end of that line isn't supposed to be there[/QUOTE] Actually lua doesn't care if it's there or not.
Sorry, you need to Log In to post a reply to this thread.