Jump to content

Help


yMassai

Recommended Posts

Posted

this?

function carrosCreateVehicle ( ) 
carrosCreateVehicles = createVehicle ( ??, 4, 0, 3 ) 
warpPedIntoVehicle ( carrosCreateVehicles ) 
end 

how can I configure to create the car selected in the list?

Community Profile MTA:SA = Click Here

  • Replies 60
  • Created
  • Last Reply

Top Posters In This Topic

Posted
guiGridListGetSelectedItem -- Get selected grid list item. 
guiGridListGetItemText -- Get the item text. 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Server

local carrosCreate = { } 
  
function carrosCreateVehicle ( ) 
carrosCreateVehicles = createVehicle ( ??, 1543.98962 , -1670.46398 , 13.0213 ) 
warpPedIntoVehicle ( carrosCreateVehicles ) 
       if ( isElement ( carrosCreateVehicle[ source ] ) ) 
        destroyElement ( carrosCreateVehicle[ source ] ) 
     end 
end 

this?

with i put?

guiGridListGetSelectedItem 
guiGridListGetItemText 

Community Profile MTA:SA = Click Here

Posted

Creating a car list:

• Create a table (vector) with the car names (you can use also the vehicle id's)

• Use the functions guiCreateGridList(), guiGridListAddColumn(), guiGridListAddRow() and guiGridListSetItemText() for create a list

• Create a loop (for i, v in ipairs(table_name) do) and insert (inside loop) the function guiGridListAddRow() and guiGridListSetItemText(). If you putted names on table, use getElementModel() for get the car id.

If you need more help, go to my profile and get my messenger address. I'm from Brazil too, and I can help you better. :)

Software Engineer & Entrepreneur Running Lustrel and VilarikA • Highly engaged on open source community

Posted

Server

local carrosCreateVehicle = { } 
  
function carrosCreateClick ( ) 
   if ( source == carrosCreateVehicle ) then 
        triggerServerEvent ( "testCreateTest", localPlayer ) 
        testDestroyTestGUI ( ) 
     if ( isElement ( carrosVehicle[ source ] ) ) 
        destroyElement ( carrosVehicle[ source ] ) 
carrosCreateVehicle = createVehicle ( ??, 1543,98962 , -1670,46398 , 13,0213 ) 
        warpPedIntoVehicle ( carrosVehicle ) 
end 
addEventHandler ( "onClientGUIClick", root, carrosCreateClick ) 

This?

Community Profile MTA:SA = Click Here

Posted

That is just a mess, I suggest you start again, you still don't understand that events/functions can't be used on both sides ( client and server ).

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
carrosWindow = guiCreateWindow(100,100,175,200,"Criador de Carros",false) 
carrosList = guiCreateGridList ( 0.05, 0.10, 0.9, 0.7, true, carrosWindow) 
column = guiGridListAddColumn( carrosList, "Cars", 0.85 ) 
carrosCreate = guiCreateButton(05,170,85,45,"Create",false,carrosWindow) 
carrosClose = guiCreateButton(110,170,50,45,"Close",false,carrosWindow) 
guiWindowSetSizable( carrosWindow,false) 
guiSetVisible( carrosWindow, false ) 
  
carrosVis = 
    { 
        440, 
        320 
    } 
for index, model in ipairs ( carrosVis ) do 
    local row = guiGridListAddRow ( carrosList ) 
    guiGridListSetItemText ( carrosList, row, column, tostring ( getVehicleNameFromModel ( model ) ), false, true ) 
end 
  
carrosMarker = createMarker( 1543.98962, -1670.46398, 12.55753, "cylinder", 1.5, 255, 0, 0, 170 ) 
createCarrosVehicle = createVehicle (??,0,0,0) 
       warpPedIntoVehicle ( carrosCreateVehicles ) 
  
addEventHandler ( "onClientMarkerHit", root, 
    function ( hitElement ) 
  
         if ( hitElement == localPlayer ) then 
            if ( source == carrosMarker ) then 
                guiSetVisible ( carrosWindow, true ) 
            end 
        end 
    end 
) 
  
addEventHandler ( "onClientGUIClick", root, 
    function ( ) 
        if ( source == carrosClose ) then 
            guiSetVisible ( carrosWindow, false ) 
        end 
    end 
) 

This?

Please help me, I have no time to start the script again.

Community Profile MTA:SA = Click Here

Posted
Clientside and Serverside scripts

You may have already noticed these or similiar terms (Server/Client) somewhere on this wiki, mostly in conjunction with functions. MTA not only supports scripts that run on the server and provide commands (like the one we wrote above) or other features, but also scripts that run on the MTA client the players use to connect to the server. The reason for this is, that some features MTA provides have to be clientside (like a GUI - Graphical User Interface), others should be because they work better and still others are better off to be serverside or just don't work clientside.

Most scripts you will make (gamemodes, maps) will probably be serverside, like the one we wrote in the first section. If you run into something that can't be solved serverside, you will probably have to make it clientside.

https://wiki.multitheftauto.com/wiki/TriggerServerEvent

https://wiki.multitheftauto.com/wiki/TriggerClientEvent

you can use this part serverside:

but you'll have to edit it slightly. As in remove the GUI functions and the player argument and marker event

carrosMarker = createMarker( 1543.98962, -1670.46398, 12.55753, "cylinder", 1.5, 255, 0, 0, 170 ) 
createCarrosVehicle = createVehicle (??,0,0,0) 
       warpPedIntoVehicle ( carrosCreateVehicles ) 
  
addEventHandler ( "onMarkerHit", root, 
    function ( hitElement ) 
  
         if ( hitElement == source ) then 
            if ( source == carrosMarker ) then 
 -- trigger client event here 
            end 
        end 
    end 
) 

then use something like this on clientside, you have to trigger it from serverside though, look comments above.

function iHitMarker() 
   guiSetVisible ( carrosWindow, false ) 
-- your gui function(s)  
-- this event should be triggered from server 
end 
addEvent( "iHitMarkerC", true ) 
addEventHandler( "iHitMarkerC", root, iHitMarker ) 

Posted

is more easy it

cl-side

carrosWindow = guiCreateWindow(100,100,175,200,"Criador de Carros",false) 
carrosList = guiCreateGridList ( 0.05, 0.10, 0.9, 0.7, true, carrosWindow) 
column = guiGridListAddColumn( carrosList, "Cars", 0.85 ) 
carrosCreate = guiCreateButton(05,170,85,45,"Create",false,carrosWindow) 
carrosClose = guiCreateButton(110,170,50,45,"Close",false,carrosWindow) 
guiWindowSetSizable( carrosWindow,false) 
guiSetVisible( carrosWindow, false ) 
row = guiGridListAddRow( carrosList ) 
row2 = guiGridListAddRow( carrosList ) 
guiGridListSetItemText( carrosList, row, column, "Rumpo", false, false ) 
guiGridListSetItemText( carrosList, row2, column, "PutUrCar", false, false ) 
  
carrosMarker = createMarker( 1543.98962, -1670.46398, 12.55753, "cylinder", 1.5, 255, 0, 0, 170 ) 
  
    function elMarker( hitPlayer ) 
         if ( hitPlayer == localPlayer ) then 
                guiSetVisible ( carrosWindow, true ) 
        end 
    end 
addEventHandler ( "onClientMarkerHit", carrosMarker, elMarker) 
  
addEventHandler ( "onClientGUIClick", root, 
    function ( ) 
        if ( source == carrosClose ) then 
            guiSetVisible ( carrosWindow, false ) 
        elseif ( source == carrosCreate ) then 
triggerServerEvent("CreateCarros", getLocalPlayer()) 
        end 
    end 
) 

sv-side

  
addEvent("CreateCarros", true) 
addEventHandler("CreateCarros", getRootElement(),  
function() 
carros = createVehicle ( 440,0,0,0) 
warpPedIntoVehicle ( carros ) 
end 
) 

elMota/elFoReX De Vuelta En MTA *---------*

Cuenta De Youtube En La Que Subo Tutoriales Acerca De MTA :3

https://www.youtube.com/user/KillersGPs

430x73_FFFFFF_FF9900_000000_000000.png
Posted

Client

carrosWindow = guiCreateWindow(100,100,175,200,"Criador de Carros",false) 
carrosList = guiCreateGridList ( 0.05, 0.10, 0.9, 0.7, true, carrosWindow) 
column = guiGridListAddColumn( carrosList, "Cars", 0.85 ) 
carrosCreate = guiCreateButton(05,170,85,45,"Create",false,carrosWindow) 
carrosClose = guiCreateButton(110,170,50,45,"Close",false,carrosWindow) 
guiWindowSetSizable( carrosWindow,false) 
guiSetVisible( carrosWindow, false ) 
row = guiGridListAddRow( carrosList ) 
row2 = guiGridListAddRow( carrosList ) 
guiGridListSetItemText( carrosList, row, column, "Rumpo", false, false ) 
guiGridListSetItemText( carrosList, row2, column, "PutUrCar", false, false ) 
  
carrosMarker = createMarker( 1543.98962, -1670.46398, 12.55753, "cylinder", 1.5, 255, 0, 0, 170 ) 
  
    function elMarker( hitPlayer ) 
         if ( hitPlayer == localPlayer ) then 
                guiSetVisible ( carrosWindow, true ) 
        end 
    end 
addEventHandler ( "onClientMarkerHit", carrosMarker, elMarker) 
  
addEventHandler ( "onClientGUIClick", root, 
    function ( ) 
        if ( source == carrosClose ) then 
            guiSetVisible ( carrosWindow, false ) 
        elseif ( source == carrosCreate ) then 
triggerServerEvent("CreateCarros", getLocalPlayer()) 
        end 
    end 
) 

Server

addEvent("CreateCarros", true) 
addEventHandler("CreateCarros", getRootElement(), 
function() 
carros = createVehicle ( 440,1543.98962, -1670.46398, 13.300, 0,0,90) 
warpPedIntoVehicle ( carros ) 
end 
) 

The warpPedIntoVehicle dont work!

Community Profile MTA:SA = Click Here

Posted

Maybe because you forgot about the first argument?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
Required Arguments

thePed: The ped which you wish to force inside the vehicle ( First )

theVehicle: The vehicle you wish to force the ped into ( Second )

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Client

carrosWindow = guiCreateWindow(100,100,175,200,"Criador de Carros",false) 
carrosList = guiCreateGridList ( 0.05, 0.10, 0.9, 0.7, true, carrosWindow) 
column = guiGridListAddColumn( carrosList, "Cars", 0.85 ) 
carrosCreate = guiCreateButton(05,170,85,45,"Create",false,carrosWindow) 
carrosClose = guiCreateButton(110,170,50,45,"Close",false,carrosWindow) 
guiWindowSetSizable( carrosWindow,false) 
guiSetVisible( carrosWindow, false ) 
row = guiGridListAddRow( carrosList ) 
row2 = guiGridListAddRow( carrosList ) 
guiGridListSetItemText( carrosList, row, column, "Rumpo", false, false ) 
guiGridListSetItemText( carrosList, row2, column, "PutUrCar", false, false ) 
  
carrosMarker = createMarker( 1543.98962, -1670.46398, 12.55753, "cylinder", 1.5, 255, 0, 0, 170 ) 
  
    function elMarker( hitPlayer ) 
         if ( hitPlayer == localPlayer ) then 
                guiSetVisible ( carrosWindow, true ) 
        end 
    end 
addEventHandler ( "onClientMarkerHit", carrosMarker, elMarker) 
  
addEventHandler ( "onClientGUIClick", root, 
    function ( ) 
        if ( source == carrosClose ) then 
            guiSetVisible ( carrosWindow, false ) 
        elseif ( source == carrosCreate ) then 
triggerServerEvent("CreateCarros", getLocalPlayer()) 
        end 
    end 
) 

Server

  
local carros = { } 
  
addEvent("CreateCarros", true) 
addEventHandler("CreateCarros", getRootElement(), 
function() 
carros = createVehicle ( 440,1543.98962, -1670.46398, 13.600, 0,0,90) 
warpPedIntoVehicle ( source, carros ) 
          if ( isElement ( carrosVehicle[ source ] ) ) 
        destroyElement ( carrosVehicle[ source ] ) 
      end 
end 
) 

to the server *

this way go create only a car?

Community Profile MTA:SA = Click Here

Posted (edited)
local carros = { } 
  
addEvent ( "CreateCarros", true ) 
addEventHandler ( "CreateCarros", getRootElement(), 
    function ( ) 
        if ( isElement ( carros [ source ] ) ) then 
            destroyElement ( carros [ source ] ) 
        end 
  
        carros [ source ] = createVehicle ( 440,1543.98962, -1670.46398, 13.600, 0, 0, 90 ) 
        warpPedIntoVehicle ( source, carros [ source ] ) 
    end 
) 

Edited by Guest

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

SCRIPT ERROR: CarrosTest\server.lua:7: 'then' expected near 'destroyElement'

WARNING: Loading script failed: CarrosTest\server.lua:7: 'then' expected near 'destroyElement'

Community Profile MTA:SA = Click Here

Posted
local carros = { } 
  
addEvent ( "CreateCarros", true ) 
addEventHandler ( "CreateCarros", getRootElement(), 
    function ( ) 
        if ( isElement ( carros [ source ] ) ) 
            destroyElement ( carros [ source ] ) 
        end 
  
        carros [ source ] = createVehicle ( 440,1543.98962, -1670.46398, 13.600, 0, 0, 90 ) 
        warpPedIntoVehicle ( source, carros [ source ] ) 
    end 
) 

local carros = { } 
  
addEvent ( "CreateCarros", true ) 
addEventHandler ( "CreateCarros", getRootElement(), 
    function ( ) 
        if ( isElement ( carros [ source ] ) ) then 
            destroyElement ( carros [ source ] ) 
        end 
  
        carros [ source ] = createVehicle ( 440,1543.98962, -1670.46398, 13.600, 0, 0, 90 ) 
        warpPedIntoVehicle ( source, carros [ source ] ) 
    end 
) 

you do not recalled the "then"

Community Profile MTA:SA = Click Here

Posted

I noticed, edited my post ;).

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

You must trigger the selected item name to server side then get the vehicle model from the name received.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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