Jump to content

[Bribe]


Fantanic

Recommended Posts

Hello ,

Im trying to make a bribe system but im not sure wich functions i got to use

I would like to have if you do /bribe then there comes a object (star ) and if u run into it You get a gui with wanted levels + price , Also i would like to have it so if u got 5 stars only 1 2 3 4 5 are showing up and not 1-6 for example.

Link to comment

One of the most important aspects of scripting for MTA is to learn how to navigate the Wiki.

Ask yourself what you want to do, take notes - think about what you'll need, write down keywords. This is a great way to learn how to navigate the wiki.

For example;

• Command

• Pickup (Bribe)

• GUI

• Wanted

With those 4 keywords, you'll find the most basic functions you need to get going. As for events, ask yourself things like this;

1. You want interaction whenever a pickup is picked up.

2. Go to Client Events, search for the keyword above - "Pickup".

3. You'll get a few results, one of them being onClientPickupHit.

4. Read about this event. "This event triggers whenever a pickup is hit clientside."

5. Perfect, exactly what you need!

Now you'll have the bare minimum stuff, finding the appropriate functions for the actual logic behind the script won't be as easy. But you'll never learn unless you give it a thorough try.

Learn how to navigate the Wiki, and understand the examples. Then you'll be able to make pretty much anything your heart may desire.

Link to comment

I perfectly understood your question, but you don't seem willing to even learn how to navigate the Wiki - which has each and every function and event you'll need.

So I don't even see any reason to help you with that attitude, have fun waiting for someone else to assist you. :roll:

Link to comment

You could create a single window and use radio buttons, then you can use a table to store them and do something like this:

local radioButtons = 
    { 
        guiCreateRadioButton ( args... ), 
        guiCreateRadioButton ( args... ), 
        guiCreateRadioButton ( args... ), 
        guiCreateRadioButton ( args... ), 
        guiCreateRadioButton ( args... ), 
        guiCreateRadioButton ( args... ) 
    } 
  
function setRadioButtonsVisible ( ) 
    for index = 1, 6 do 
        guiSetVisible ( radioButtons [ index ], false ) 
    end 
  
    for index = 1, getPlayerWantedLevel ( ) do 
        guiSetVisible ( radioButtons [ index ], true ) 
    end 
end 

Link to comment
  
  
function bribegui() 
        GUIEditor.window[1] = guiCreateWindow(310, 165, 112, 153, "", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
  
        GUIEditor.radiobutton[1] = guiCreateRadioButton(9, 31, 93, 15, "1 star", false, GUIEditor.window[1]) 
        GUIEditor.radiobutton[2] = guiCreateRadioButton(10, 46, 92, 15, "2 star", false, GUIEditor.window[1]) 
        GUIEditor.radiobutton[3] = guiCreateRadioButton(10, 61, 92, 15, "3 star", false, GUIEditor.window[1]) 
        GUIEditor.radiobutton[4] = guiCreateRadioButton(9, 76, 93, 15, "4 star", false, GUIEditor.window[1]) 
        GUIEditor.radiobutton[5] = guiCreateRadioButton(10, 91, 92, 15, "5 star", false, GUIEditor.window[1]) 
        guiRadioButtonSetSelected(GUIEditor.radiobutton[5], true) 
        GUIEditor.radiobutton[6] = guiCreateRadioButton(10, 106, 92, 15, "6 star", false, GUIEditor.window[1])     
    end 
  
  

  
  
function offerbribe() 
local theObject = createObject ( (star object i need list where to find the star object ID), x + 2, y + 2, z, 0, 0, 0 ) 
local tempCol = createColTube ( fX + 2, fY + 2, fZ, 10.0, 10.0 ) 
end 
addCommandHandler("bribe",offerbribe) 
  

Like this? (i still need the object id list of pickups btw)

Like this?

Link to comment
  
  
  
function bribegui() 
        GUIEditor.window[1] = guiCreateWindow(310, 165, 112, 153, "Bribe", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
  
        GUIEditor.radiobutton[1] = guiCreateRadioButton(9, 31, 93, 15, "1 star", false, GUIEditor.window[1]) 
        GUIEditor.radiobutton[2] = guiCreateRadioButton(10, 46, 92, 15, "2 star", false, GUIEditor.window[1]) 
        GUIEditor.radiobutton[3] = guiCreateRadioButton(10, 61, 92, 15, "3 star", false, GUIEditor.window[1]) 
        GUIEditor.radiobutton[4] = guiCreateRadioButton(9, 76, 93, 15, "4 star", false, GUIEditor.window[1]) 
        GUIEditor.radiobutton[5] = guiCreateRadioButton(10, 91, 92, 15, "5 star", false, GUIEditor.window[1]) 
        guiRadioButtonSetSelected(GUIEditor.radiobutton[5], true) 
        GUIEditor.radiobutton[6] = guiCreateRadioButton(10, 106, 92, 15, "6 star", false, GUIEditor.window[1])     
  
    guiSetVisible(GUIEditor.window[1],true)  --- asfar im aware this is right 
    end 
  
  
  
function offerbribe() 
local bribePick = createPickUp(1247, x +2, y +2, z)  
end 
addCommandHandler("bribe",offerbribe) 
  
addEventHandler("onPickUpHit",bribePick, bribegui) --- im not sure about this one here 
  
  

i know i miss some things but i dont know what

Link to comment

Wrong !

you should make a function every time you do eventHandlers or even CommadHandlers....

For example.

I want 20% extra health. So we do this:

function forThePick () 
   pickle = createPickUp(1247, x +2, y +2, z) 
end 
addCommandHandler("bribe", forThePick) 
  
function dipsit (hitElement) 
   if hitElement == localPlayer then 
   if source == pickle then 
   takePlayerMoney(5000) 
   local tatta = getElementHealth(localPlayer) 
   setElementHealth(localPlayer, tonumber(tatta)+20) 
   end 
   end 
end 
addEventHandler("onPickUpHit", getRootElement(), dipsit) 

see? Make it that way. The script I gave now may contain some errors but they are minor and can be fixed self.

Link to comment

So if im right i got to split the function?

Edit , but i cant split it here if im right or am i wrong?

or

  
  
function bribepickup() 
guiSetVisible(bribegui,true) 
addEventHandler("onPickupHit",offerbribe,bribepickup) 
  

excuse me if im wrong im trying to learn more of LUA

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...