PDA

View Full Version : Whats wrong with this Command?


Xeonon
04-09-2009, 11:27 PM
Hi guys I want to make it so a police officer does /sus <playerID/playerName> <Reason>
And so other officers can't suspect each other. And also so it shows that Officer Xeonon suspected Player Name for Reason.

Here is my code so far.

function SuspectPlayer(PlayerID, Player2, Reason)
if not Player2 then
outputChatBox ( PlayerID,"SYNTAX: //suspect Player Reason", 255, 0, 0, 255 )
elseif isPlayerSpawned ( PlayerID ) == 0 then
outputChatBox(PlayerID, "You must be spawned", 255, 0, 0, 255 )
else
setPlayerFixedWantedLevel (PlayerID, 1)
end
end

addCommand("sus", "SuspectPlayer")


Edit: I also wan't it to give a officer about $500 if he kills a suspect ;)

Mantis
04-10-2009, 11:28 AM
function suspectPlayer(PlayerID,TargetID,Text)
local Reason = {}

if TargetID == nil or Reason == nil then
outputChatBox(PlayerID,"Syntax: /suspect [ID] [Reason]",255,0,0,255) return end
if isPlayerSpawned(PlayerID) == 0 then
outputChatBox(PlayerID,"Error: You must be spawned.",255,0,0,255) return end
if isPlayerConnected(TargetID) == 0 then
outputChatBox(PlayerID,"Error: Player not connected.",255,0,0,255) return end
if strval(PlayerID) == strval(TargetID) then
outputChatBox(PlayerID,"Error: You can not suspect yourself.",255,0,0,255) return end
setPlayerWantedLevel(TargetID,2)
outputChatBox("Cop Radio: " .. getPlayerName(TargetID) .. " has been suspected by " .. getPlayerName(PlayerID) .. " for: " .. Text,255,0,0,255)
end

addCommand("suspect","suspectPlayer")

function onPlayerDeath(PlayerID,KillerID)
-- Cop - Suspect Money
if getPlayerWantedLevel(PlayerID) > 0 then
outputChatBox(PlayerID,"You were taken down as a suspect, the cop gets $500 as reward!",255,0,0,255)
outputChatBox(KillerID,"You took out a suspect, you get $500 as a reward!",255,0,0,255)
givePlayerCash(KillerID,500)
setPlayerWantedLevel(PlayerID,0)
end
end

That's fully working for you.
If you have onPlayerDeath already in your script, you'll have to paste it under there.

Xeonon
04-10-2009, 02:02 PM
Hey man Thanks! Now Im working on a wanted command and a jail command! Having a few troubles with both :(