I found that cops always get pissed when they're trying to arrest someone and the person always just runs away and shoots at them. I figured this problem could be solved if the person that's wanted cannot sprint. I'm a noob at lua coding so I figured I'd request the code here.
Here's the wanted/unwanted code from the main.lua file in the darkrp gamemode.
[code]local function PlayerWanted(ply, args)
local t = ply:Team()
if t ~= TEAM_POLICE and t ~= TEAM_MAYOR and t ~= TEAM_CHIEF then
Notify(ply, 1, 6, string.format(LANGUAGE.must_be_x, "cop/mayor", "/wanted"))
else
local tableargs = string.Explode(" ", args)
local reason = ""
if #tableargs == 1 then
Notify(ply, 1, 4, LANGUAGE.vote_specify_reason)
return ""
end
for i = 2, #tableargs, 1 do
reason = reason .. " " .. tableargs[i]
end
reason = string.sub(reason, 2)
if string.len(reason) > 22 then
Notify(ply, 1, 4, string.format(LANGUAGE.unable, "/wanted", "<23 chars"))
return ""
end
local p = FindPlayer(tableargs[1])
if p and p:Alive() and not RPArrestedPlayers[p:SteamID()] and not p.DarkRPVars.wanted then
p:SetDarkRPVar("wanted", true)
p:SetDarkRPVar("wantedReason", tostring(reason))
for a, b in pairs(player.GetAll()) do
b:PrintMessage(HUD_PRINTCENTER, string.format(LANGUAGE.wanted_by_police, p:Nick()).."\nReason: "..tostring(reason))
timer.Create(p:Nick() .. " wantedtimer", GetConVarNumber("wantedtime"), 1, TimerUnwanted, ply, p)
end
else
Notify(ply, 1, 4, string.format(LANGUAGE.could_not_find, "player: "..tostring(args)))
end
end
return ""
end
AddChatCommand("/wanted", PlayerWanted)
local function PlayerUnWanted(ply, args)
local t = ply:Team()
if not (t == TEAM_POLICE or t == TEAM_MAYOR or t == TEAM_CHIEF) then
Notify(ply, 1, 6, string.format(LANGUAGE.must_be_x, "cop/mayor", "/unwanted"))
else
local p = FindPlayer(args)
if p and p:Alive() and p.DarkRPVars.wanted then
p:SetDarkRPVar("wanted", false)
for a, b in pairs(player.GetAll()) do
b:PrintMessage(HUD_PRINTCENTER, string.format(LANGUAGE.wanted_expired, p:Nick()))
timer.Destroy(p:Nick() .. " wantedtimer")
end
else
Notify(ply, 1, 4, string.format(LANGUAGE.could_not_find, "Player: "..tostring(args)))
end
end
return ""
end
AddChatCommand("/unwanted", PlayerUnWanted)[/code]
Any help would be greatly appreciated.
[code]local function PlayerWanted(ply, args)
local t = ply:Team()
if t ~= TEAM_POLICE and t ~= TEAM_MAYOR and t ~= TEAM_CHIEF then
Notify(ply, 1, 6, string.format(LANGUAGE.must_be_x, "cop/mayor", "/wanted"))
else
local tableargs = string.Explode(" ", args)
local reason = ""
if #tableargs == 1 then
Notify(ply, 1, 4, LANGUAGE.vote_specify_reason)
return ""
end
for i = 2, #tableargs, 1 do
reason = reason .. " " .. tableargs[i]
end
reason = string.sub(reason, 2)
if string.len(reason) > 22 then
Notify(ply, 1, 4, string.format(LANGUAGE.unable, "/wanted", "<23 chars"))
return ""
end
local p = FindPlayer(tableargs[1])
if p and p:Alive() and not RPArrestedPlayers[p:SteamID()] and not p.DarkRPVars.wanted then
GAMEMODE:SetPlayerSpeed(p, GetConVarNumber("aspd"), GetConVarNumber("aspd"))
p:SetDarkRPVar("wanted", true)
p:SetDarkRPVar("wantedReason", tostring(reason))
for a, b in pairs(player.GetAll()) do
b:PrintMessage(HUD_PRINTCENTER, string.format(LANGUAGE.wanted_by_police, p:Nick()).."\nReason: "..tostring(reason))
timer.Create(p:Nick() .. " wantedtimer", GetConVarNumber("wantedtime"), 1, TimerUnwanted, ply, p)
end
else
Notify(ply, 1, 4, string.format(LANGUAGE.could_not_find, "player: "..tostring(args)))
end
end
return ""
end
AddChatCommand("/wanted", PlayerWanted)
local function PlayerUnWanted(ply, args)
local t = ply:Team()
if not (t == TEAM_POLICE or t == TEAM_MAYOR or t == TEAM_CHIEF) then
Notify(ply, 1, 6, string.format(LANGUAGE.must_be_x, "cop/mayor", "/unwanted"))
else
local p = FindPlayer(args)
if p and p:Alive() and p.DarkRPVars.wanted then
p:SetDarkRPVar("wanted", false)
for a, b in pairs(player.GetAll()) do
GAMEMODE:SetPlayerSpeed(p, GetConVarNumber("wspd"), GetConVarNumber("rspd"))
b:PrintMessage(HUD_PRINTCENTER, string.format(LANGUAGE.wanted_expired, p:Nick()))
timer.Destroy(p:Nick() .. " wantedtimer")
end
else
Notify(ply, 1, 4, string.format(LANGUAGE.could_not_find, "Player: "..tostring(args)))
end
end
return ""
end
AddChatCommand("/unwanted", PlayerUnWanted)[/code]
Here.
You should be changing default garrysmod movement speeds. Everyone runs like niggers on steroids with sprint.
rp_setrunspeed;
rp_setwalkspeed
in console
[QUOTE=czmate10;24106511]rp_setrunspeed;
rp_setwalkspeed
in console[/QUOTE]
Get out
I think you would rather do it in a think hook, let me slap something up
[QUOTE=czmate10;24105398](code)
Here.[/QUOTE]
Wow, thanks so much! I'm going to try this out and post the results.
RESULTS: It seemed to work fine at first. I went into single player and went cp and wanted myself and I couldn't run. However, after I was unwanted I still couldn't sprint. After I killed myself I was able to sprint again, but I wanted to test it at a higher speed. I changed the rp_walkspeed and the rp_runspeed through the console to something faster but my character was still going the slow old speed until I killed myself again. (perhaps the commands only take effect after suicide?) Then I tried wanting myself again and I was going much slower than my set walkspeed. Are you changing the commands from the default settings or getting the current settings and changing them? Next I tried making myself wanted and then killing myself. After I respawned I was able to sprint again even though I was still wanted. Finally I was wondering if you're just changing the walkspeed and runspeed isn't it going to affect the whole server not just the person that's wanted? I can't really test that because I don't want to upload it to the server without making sure it works first. Just wanted to point that out in case you hadn't thought of it.
buh bump tsh
Sorry, you need to Log In to post a reply to this thread.