Jump to content

Meter todos los vehiculos en una lista?!


Soren

Recommended Posts

Posted

Hola a todos, Necesito meter todos los vehiculos en una lista! (Grid List) Pero no se como. :/ Porfavor ayudenme. Porfavor Solid

Posted
Explicame eso de "todos"

Quiero meter absolutamente todos los vehiculos de GTA SA En un GridList, y quiero poner un boton que Diga Spawn Vehicle y lo sSpawne

Posted

Decis todos los vehiculos del GTA? si es asi, entonces usa esta tabla ( no es mia, esta en la wiki ):

vehicleIDS = { 602, 545, 496, 517, 401, 410, 518, 600, 527, 436, 589, 580, 419, 439, 533, 549, 526, 491, 474, 445, 467, 604, 426, 507, 547, 585, 
405, 587, 409, 466, 550, 492, 566, 546, 540, 551, 421, 516, 529, 592, 553, 577, 488, 511, 497, 548, 563, 512, 476, 593, 447, 425, 519, 520, 460, 
417, 469, 487, 513, 581, 510, 509, 522, 481, 461, 462, 448, 521, 468, 463, 586, 472, 473, 493, 595, 484, 430, 453, 452, 446, 454, 485, 552, 431,  
438, 437, 574, 420, 525, 408, 416, 596, 433, 597, 427, 599, 490, 432, 528, 601, 407, 428, 544, 523, 470, 598, 499, 588, 609, 403, 498, 514, 524,  
423, 532, 414, 578, 443, 486, 515, 406, 531, 573, 456, 455, 459, 543, 422, 583, 482, 478, 605, 554, 530, 418, 572, 582, 413, 440, 536, 575, 534,  
567, 535, 576, 412, 402, 542, 603, 475, 449, 537, 538, 441, 464, 501, 465, 564, 568, 557, 424, 471, 504, 495, 457, 539, 483, 508, 571, 500,  
444, 556, 429, 411, 541, 559, 415, 561, 480, 560, 562, 506, 565, 451, 434, 558, 494, 555, 502, 477, 503, 579, 400, 404, 489, 505, 479, 442, 458,  
606, 607, 610, 590, 569, 611, 584, 608, 435, 450, 591, 594 } 

Luego usas un loop de "ipairs" y con las funciones de GUI grid list:

guiGridListAddRow 
guiGridListSetItemText 

Posted

Mil gracias Solid. Esto es lo que hice:

----------Vehiculos------------ 
lisveh = { 602, 545, 496, 517, 401, 410, 518, 600, 527, 436, 589, 580, 419, 439, 533, 549, 526, 491, 474, 445, 467, 604, 426, 507, 547, 585, 
405, 587, 409, 466, 550, 492, 566, 546, 540, 551, 421, 516, 529, 592, 553, 577, 488, 511, 497, 548, 563, 512, 476, 593, 447, 425, 519, 520, 460, 
417, 469, 487, 513, 581, 510, 509, 522, 481, 461, 462, 448, 521, 468, 463, 586, 472, 473, 493, 595, 484, 430, 453, 452, 446, 454, 485, 552, 431, 
438, 437, 574, 420, 525, 408, 416, 596, 433, 597, 427, 599, 490, 432, 528, 601, 407, 428, 544, 523, 470, 598, 499, 588, 609, 403, 498, 514, 524, 
423, 532, 414, 578, 443, 486, 515, 406, 531, 573, 456, 455, 459, 543, 422, 583, 482, 478, 605, 554, 530, 418, 572, 582, 413, 440, 536, 575, 534, 
567, 535, 576, 412, 402, 542, 603, 475, 449, 537, 538, 441, 464, 501, 465, 564, 568, 557, 424, 471, 504, 495, 457, 539, 483, 508, 571, 500, 
444, 556, 429, 411, 541, 559, 415, 561, 480, 560, 562, 506, 565, 451, 434, 558, 494, 555, 502, 477, 503, 579, 400, 404, 489, 505, 479, 442, 458, 
606, 607, 610, 590, 569, 611, 584, 608, 435, 450, 591, 594 } 
----------Vehiculos------------ 
  
  
GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Label = {} 
GUIEditor_Edit = {} 
GUIEditor_Grid = {} 
  
ventana = guiCreateWindow(499,196,625,515,"",false) 
lista = guiCreateGridList(22,47,407,438,false,ventana) 
guiGridListSetSelectionMode(lista,2) 
busqueda = guiCreateEdit(434,75,178,25,"",false,ventana) 
texto = guiCreateLabel(456,53,125,21,"Fast Serch:",false,ventana) 
spawnear = guiCreateButton(433,410,175,57,"Spawn Vehicle",false,ventana) 
columna = guiGridListAddColumn ( lista, "Vehicle", 47) 
seleccion = guiGridListAddRow (lista) 
  
function agregarvehiculos () 
    if columna then 
    for i, v in ipairs(getElementsByType("vehicle") 
        guiGridListSetItemText (lista, seleccion, columna, getVehicleName(v), true, true) 
        end 
    end 
end 
addEventHandler ( "onClientResourceStart", getResourceRootElement(), agregarvehiculos ) 

Pero ahora no se como hacer spanear los Vehiculos. Ayudame pls

Posted

Usa triggerServerEvent.

Pero primero debes obtener el vehiculo seleccionado:

-- client side:

guiGridListGetSelectedItem 
guiGridListGetItemText 
getVehicleModelFromName 
triggerServerEvent 

-- server side:

addEvent 
addEventHandler 
createVehicle 

Posted
Usa triggerServerEvent.

Pero primero debes obtener el vehiculo seleccionado:

-- client side:

guiGridListGetSelectedItem 
guiGridListGetItemText 
getVehicleModelFromName 
triggerServerEvent 

-- server side:

addEvent 
addEventHandler 
createVehicle 

Como puedo usar el "getVehicleModelFromName"? Esto es como lo intente:

function spawnearvehiculo () 
    guiGridListGetSelectedItem (lista) 
    guiGridListGetItemText (lista, seleccion, columna) 
        getVehicleModelFromName("") 

Posted
Eso no tiene sentido, empeza a pensar como podria funcionar.

Esto es lo que me dice el Syntax

getVehicleModelFromName ( string name ) 

Pero como se supone que estoy consiguiendo el nombre del Row n ose como utilizarlo

Posted
Ya te dije como, usa las funciones que te di.
function spawnearvehiculo () 
    1 = guiGridListGetSelectedItem (lista) 
    2 = guiGridListGetItemText (lista, seleccion, columna) 
        getVehicleModelFromName("2") 

Fuck!, no entiendo

Posted
soren talvez esto funcione.

getVehicleModelFromName(guiGridListGetItemText (lista, seleccion, columna))

Pero el syntax dice que debe ser string

Posted

Esto es lo que hice.

Client:

----------Vehiculos------------ 
lisveh = { 602, 545, 496, 517, 401, 410, 518, 600, 527, 436, 589, 580, 419, 439, 533, 549, 526, 491, 474, 445, 467, 604, 426, 507, 547, 585, 
405, 587, 409, 466, 550, 492, 566, 546, 540, 551, 421, 516, 529, 592, 553, 577, 488, 511, 497, 548, 563, 512, 476, 593, 447, 425, 519, 520, 460, 
417, 469, 487, 513, 581, 510, 509, 522, 481, 461, 462, 448, 521, 468, 463, 586, 472, 473, 493, 595, 484, 430, 453, 452, 446, 454, 485, 552, 431, 
438, 437, 574, 420, 525, 408, 416, 596, 433, 597, 427, 599, 490, 432, 528, 601, 407, 428, 544, 523, 470, 598, 499, 588, 609, 403, 498, 514, 524, 
423, 532, 414, 578, 443, 486, 515, 406, 531, 573, 456, 455, 459, 543, 422, 583, 482, 478, 605, 554, 530, 418, 572, 582, 413, 440, 536, 575, 534, 
567, 535, 576, 412, 402, 542, 603, 475, 449, 537, 538, 441, 464, 501, 465, 564, 568, 557, 424, 471, 504, 495, 457, 539, 483, 508, 571, 500, 
444, 556, 429, 411, 541, 559, 415, 561, 480, 560, 562, 506, 565, 451, 434, 558, 494, 555, 502, 477, 503, 579, 400, 404, 489, 505, 479, 442, 458, 
606, 607, 610, 590, 569, 611, 584, 608, 435, 450, 591, 594 } 
----------Vehiculos------------ 
  
  
GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Label = {} 
GUIEditor_Edit = {} 
GUIEditor_Grid = {} 
  
ventana = guiCreateWindow(499,196,625,515,"",false) 
lista = guiCreateGridList(22,47,407,438,false,ventana) 
guiGridListSetSelectionMode(lista,2) 
busqueda = guiCreateEdit(434,75,178,25,"",false,ventana) 
texto = guiCreateLabel(456,53,125,21,"Fast Serch:",false,ventana) 
spawnear = guiCreateButton(433,410,175,57,"Spawn Vehicle",false,ventana) 
columna = guiGridListAddColumn ( lista, "Vehicle", 47) 
seleccion = guiGridListAddRow (lista) 
  
function agregarvehiculos () 
    if columna then 
    for i, v in ipairs(getElementsByType("vehicle") 
        guiGridListSetItemText (lista, seleccion, columna, getVehicleName(v), true, true) 
        end 
    end 
end 
addEventHandler ( "onClientResourceStart", getResourceRootElement(), agregarvehiculos ) 
  
function spawnearvehiculo () 
    guiGridListGetSelectedItem (lista) 
    guiGridListGetItemText (lista, seleccion, columna) 
    local elvehiculo = getVehicleModelFromName(guiGridListGetItemText (lista, seleccion, columna)) 
    triggerServerEvent("crearVehiculo", getLocalPlayers) 
addEventHandler ( "onClientGUIClick", spawnear, spawnearvehiculo ) 

Server:

local x, y, z = getPlayerPosition 
  
function crearvehiculo () 
    createVehicle ( elvehiculo, x, y + 5, z ) 
addEvent ("crearVehiculo", true) 
addEventHandler ("crearVehiculo", getRootElement(), crearvehiculo) 

Creo que funcionara, dime si encontraste errores, pero quiero hacer otra cosa. Soy muy malo con los Commandos, pero quiero hacer que al escribir /v se abra la ventana. Y tambien quiero hacer que se pueda buscar un nombre especifico, en el edit.

Posted

Te hago el debugger a simple vista :

Linea 1 - Server side = No existe esa funcion...Usa getElementPosition(elemento)

Linea 41 - Client side = No existe getLocalPlayers...Usa el rootElement si queres poner a todos los jugadores.

Linea 30 - Client side = Te falto un "do"

Linea 4 - Server side = el primer argumento de la funcion createVehicle, es un nil value (Osea, no declaraste la variable "elvehiculo")

Posted

Entendi todo menos esta:

Linea 4 - Server side = el primer argumento de la funcion createVehicle, es un nil value (Osea, no declaraste la variable "elvehiculo")

A que te refieres?

Posted

Osea "elvehiculo" sale de la nada, no declaraste de donde sale. Lo que tenes que hacer es que en el triggerServerEvent, agregar esta variable (fijate en la wiki como es lo de los parametros opcionales). Osea, lo declaraste en client-side pero lo tenes que pasar a server.

Posted
Osea "elvehiculo" sale de la nada, no declaraste de donde sale. Lo que tenes que hacer es que en el triggerServerEvent, agregar esta variable (fijate en la wiki como es lo de los parametros opcionales). Osea, lo declaraste en client-side pero lo tenes que pasar a server.

Mira este es el unico error que me da:

[2012-06-03 18:32:44] Starting US_VehiclesSpawn 
[2012-06-03 18:32:44] SCRIPT ERROR: US_VehiclesSpawn\Server.lua:6: 'end' expected (to close 'function' at line 1) near '<eof>' 
[2012-06-03 18:32:44] WARNING: Loading script failed: US_VehiclesSpawn\Server.lua:6: 'end' expected (to close 'function' at line 1) near '<eof>' 
[2012-06-03 18:32:44] US_VehiclesSpawn restarted successfully 

Posted
Si no podes corregir ese error, te recomiendo que repases scripteo de vuelta. = end of file, expected = se esperaba...

Perdona mi ignorancia, ya repase varias veces. Y lo que puso Solid en el foro en Ingles de verdad me ofendio, yo n oquiero el script hecho, yo solo quiero que me ayuden con mis problemas T_T. Dice que hay un end serca de la linea 1 donde tengo el function. o.O No hay nada

Posted

@ElMota: Lo habias Posteado antes pero aqui esta denuevo

Client:

----------Vehiculos------------ 
lisveh = { 602, 545, 496, 517, 401, 410, 518, 600, 527, 436, 589, 580, 419, 439, 533, 549, 526, 491, 474, 445, 467, 604, 426, 507, 547, 585, 
405, 587, 409, 466, 550, 492, 566, 546, 540, 551, 421, 516, 529, 592, 553, 577, 488, 511, 497, 548, 563, 512, 476, 593, 447, 425, 519, 520, 460, 
417, 469, 487, 513, 581, 510, 509, 522, 481, 461, 462, 448, 521, 468, 463, 586, 472, 473, 493, 595, 484, 430, 453, 452, 446, 454, 485, 552, 431, 
438, 437, 574, 420, 525, 408, 416, 596, 433, 597, 427, 599, 490, 432, 528, 601, 407, 428, 544, 523, 470, 598, 499, 588, 609, 403, 498, 514, 524, 
423, 532, 414, 578, 443, 486, 515, 406, 531, 573, 456, 455, 459, 543, 422, 583, 482, 478, 605, 554, 530, 418, 572, 582, 413, 440, 536, 575, 534, 
567, 535, 576, 412, 402, 542, 603, 475, 449, 537, 538, 441, 464, 501, 465, 564, 568, 557, 424, 471, 504, 495, 457, 539, 483, 508, 571, 500, 
444, 556, 429, 411, 541, 559, 415, 561, 480, 560, 562, 506, 565, 451, 434, 558, 494, 555, 502, 477, 503, 579, 400, 404, 489, 505, 479, 442, 458, 
606, 607, 610, 590, 569, 611, 584, 608, 435, 450, 591, 594 } 
----------Vehiculos------------ 
  
  
GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Label = {} 
GUIEditor_Edit = {} 
GUIEditor_Grid = {} 
  
ventana = guiCreateWindow(499,196,625,515,"",false) 
lista = guiCreateGridList(22,47,407,438,false,ventana) 
guiGridListSetSelectionMode(lista,2) 
busqueda = guiCreateEdit(434,75,178,25,"",false,ventana) 
texto = guiCreateLabel(456,53,125,21,"Fast Serch:",false,ventana) 
spawnear = guiCreateButton(433,410,175,57,"Spawn Vehicle",false,ventana) 
columna = guiGridListAddColumn ( lista, "Vehicle", 47) 
seleccion = guiGridListAddRow (lista) 
  
function agregarvehiculos () 
    if columna then 
    for i, v in ipairs(getElementsByType("vehicle") do 
        guiGridListSetItemText (lista, seleccion, columna, getVehicleName(v), true, true) 
        end 
    end 
end 
addEventHandler ( "onClientResourceStart", getResourceRootElement(), agregarvehiculos ) 
  
function spawnearvehiculo () 
    guiGridListGetSelectedItem (lista) 
    guiGridListGetItemText (lista, seleccion, columna) 
    local elvehiculo = getVehicleModelFromName(guiGridListGetItemText (lista, seleccion, columna)) 
    triggerServerEvent("crearVehiculo", getRootElement) 
addEventHandler ( "onClientGUIClick", spawnear, spawnearvehiculo ) 

Server:

function crearvehiculo (player) 
local x, y, z = getElementPosition(player) 
  
    createVehicle ( elvehiculo, x, y + 5, z ) 
addEvent ("crearVehiculo", true) 
addEventHandler ("crearVehiculo", getRootElement(), crearvehiculo) 

Posted

1: En el server side te falta un end.

2: En el client side usas las funciones: guiGridListGetSelectedItem, guiGridListGetItemText pero no las definis.

3: Envias "getRootElement" en lugar de "localPlayer" en triggerServerEvent.

4: Mejor no sigo.

  • Recently Browsing   0 members

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