Jump to content

Basic jail script help.


knash94

Recommended Posts

  
function normalworld ( robber ) 
setElementInterior ( robber, 0 ) 
setElementPosition ( robber, 430.39071655273, 2501.9091796875, 18.580074457397 ) 
outputChatBox("You should of been let out by now", robber) 
end 
  
  
function arrest ( thePlayer, command, robber ) 
robber = getPlayerFromNick(robber) 
local playerTeam = getPlayerTeam ( thePlayer ) 
   if ( playerTeam == Police ) then 
    if ( robber ) then 
     local level = getPlayerWantedLevel( robber ) 
     if ( level >= 1 ) then 
            setElementInterior ( robber, 10, 219.89385986328, 111.19395446777, 999.015625  ) 
            if ( level == 1 ) then 
                givePlayerMoney ( thePlayer, 250 ) 
                setPlayerWantedLevel( robber, 0 ) 
                setTimer ( normalworld, 30000, 1 ) 
                outputChatBox("You'r now in jail for 30 seconds.", robber) 
                outputChatBox("You have sent" .. robber .. " to jail. You are rewarded $250", thePlayer) 
            elseif ( level == 2 ) then 
                givePlayerMoney ( thePlayer, 350 ) 
                setPlayerWantedLevel( robber, 0 ) 
                setTimer ( normalworld, 45000, 1 ) 
                outputChatBox("You'r now in jail for 45 seconds.", robber) 
                outputChatBox("You have sent" .. robber .. " to jail. You are rewarded $350", thePlayer) 
            elseif ( level == 3 ) then 
                givePlayerMoney ( thePlayer, 500 ) 
                setPlayerWantedLevel( robber, 0 ) 
                setTimer ( normalworld, 60000, 1 ) 
                outputChatBox("You'r now in jail for 60 seconds.", robber) 
                outputChatBox("You have sent" .. robber .. " to jail. You are rewarded $500", thePlayer) 
            elseif ( level == 4 ) then 
                givePlayerMoney ( thePlayer, 650 ) 
                setPlayerWantedLevel( robber, 0 ) 
                setTimer ( normalworld, 90000, 1 ) 
                outputChatBox("You'r now in jail for 90 seconds.", robber) 
                outputChatBox("You have sent" .. robber .. " to jail. You are rewarded $650", thePlayer) 
            elseif ( level == 5 ) then 
                givePlayerMoney ( thePlayer, 800 ) 
                setPlayerWantedLevel( robber, 0 ) 
                setTimer ( normalworld, 150000, 1 ) 
                outputChatBox("You'r now in jail for 150 seconds.", robber) 
                outputChatBox("You have sent" .. robber .. " to jail. You are rewarded $800", thePlayer) 
            elseif ( level == 6 ) then 
                givePlayerMoney ( thePlayer, 1000 ) 
                setPlayerWantedLevel( robber, 0 ) 
                setTimer ( normalworld, 250000, 1 ) 
                outputChatBox("You'r now in jail for 250 seconds.", robber) 
                outputChatBox("You have sent" .. robber .. " to jail. You are rewarded $1000", thePlayer) 
            end 
     else 
      outputChatBox("This target is not wanted", thePlayer) 
     end 
    else 
    outputChatBox("You have not selected anyone.", thePlayer) 
    end 
   else 
   outputChatBox("You are not a part of the police force.", thePlayer) 
   end 
end 
addCommandHandler("arrest", arrest) 
  

Well what the problem is that "function normalworld ( robber )" does not know who to release from jail. Is there anything i can change which will make it know who to release? Thank you. Im tired right now if im not making much sense :P

Link to comment

Modify the setTimer lines so the fourth argument is the player being jailed.

  
setTimer ( normalworld, 90000, 1 , robber) 
  

Also, you made some unrelated grammatical mistakes...

should of -> should have

You'r -> You're or You are

Other than that, this is good for a relative newcomer, keep it up. ;)

Link to comment

Well im trying to make my own one for dp2.3 i will try improoving it quite a bit every week or so then ill eventually go onto nightly builds and start getting it ready for mta1.0 :) But thanks. It looks like a real nice script.

Link to comment

Sorry to double post but if i dont people wont reply...

Other than making a new topic i think its a better idea just to ask for help on this one :P

Can anyone please post an example of a working SQL ingame with money and player names (With working query's for setplayermoney (or w.e it is) ) , yes ive tried it and it fails.. im too embarresd to even post it on the forums lol. Any way, anyone who can help is a legend :)

Link to comment

Wrong... New topic = new topic, IMO...

As for SQL, what I did (that makes the job significantly easier) was download a little something called SQLite Administrator. It lets you create tables in the database with a GUI instead of cocking around with long complicated CREATE TABLE lines.

For the code itself, there are already plenty of examples on the wiki, which you need to learn to use properly. Search functions, the list of functions...

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...