Jump to content

Help


yMassai

Recommended Posts

  • Replies 60
  • Created
  • Last Reply

Top Posters In This Topic

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 

Link to comment

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

Link to comment

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?

Link to comment
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.

Link to comment
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 ) 

Link to comment

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 
) 

Link to comment

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!

Link to comment

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?

Link to comment
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
Link to comment
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"

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