Jump to content

Cars


eAd

Recommended Posts

Posted

repir this code

cient

  
GUIEditor = { 
    gridlist = {}, 
    memo = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        wnd = guiCreateWindow(191, 82, 474, 427, "[PS] Cars System By Mostafa", false) 
        guiWindowSetSizable(wnd, false) 
        guiSetAlpha(wnd, 0.92) 
        guiSetProperty(wnd, "CaptionColour", "FF788D6B") 
  
        1 = guiCreateButton(9, 19, 129, 79, "NGR-500", false, wnd) 
        guiSetFont(1, "default-small") 
        guiSetProperty(1, "NormalTextColour", "FF1A0AF4") 
        2 = guiCreateButton(9, 130, 129, 73, "Banshee", false, wnd) 
        guiSetFont(2, "default-small") 
        guiSetProperty(2, "NormalTextColour", "FF24F508") 
        3 = guiCreateButton(9, 258, 129, 70, "BMX", false, wnd) 
        guiSetFont(3, "default-small") 
        guiSetProperty(3, "NormalTextColour", "FFF92603") 
        5 = guiCreateButton(155, 20, 116, 78, "Alpha", false, wnd) 
        guiSetFont(5, "default-small") 
        guiSetProperty(5, "NormalTextColour", "FFC536C3") 
        6 = guiCreateButton(154, 139, 136, 64, "GTR-500", false, wnd) 
        guiSetFont(6, "default-small") 
        guiSetProperty(6, "NormalTextColour", "FF1909F1") 
        7 = guiCreateButton(164, 266, 136, 62, "Bobcat", false, wnd) 
        guiSetFont(7, "default-small") 
        guiSetProperty(7, "NormalTextColour", "FF05DBF4") 
        GUIEditor.memo[1] = guiCreateMemo(12, 334, 298, 83, "New Cars In GridList \n\n,Mostafa [PS]\n\nUpdate : Add Yamaha R1", false, wnd) 
        GUIEditor.gridlist[1] = guiCreateGridList(319, 24, 145, 393, false, wnd) 
        guiGridListAddColumn(GUIEditor.gridlist[1], "New Cars", 0.9) 
        for i = 1, 4 do 
            guiGridListAddRow(GUIEditor.gridlist[1]) 
        end 
        guiGridListSetItemText(GUIEditor.gridlist[1], 0, 1, "BMW|SOON", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 1, 1, "Ferari|SOON", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 2, 1, "PS Car| SOON", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 3, 1, "Yamaha R1 ", false, false)     
    end 
) 
addEventHandler ( 'onClientGUIClick', resourceRoot, function( ) 
    if ( source == 1) then 
        triggerServerEvent ( 'car1', localPlayer ) 
        end 
    end 
) 
addEventHandler ( 'onClientGUIClick', resourceRoot, function( ) 
    if ( source == 2) then 
        triggerServerEvent ( 'car2', localPlayer ) 
        end 
    end 
) 
addEventHandler ( 'onClientGUIClick', resourceRoot, function( ) 
    if ( source == 3) then 
        triggerServerEvent ( 'car3', localPlayer ) 
        end 
    end 
) 
addEventHandler ( 'onClientGUIClick', resourceRoot, function( ) 
    if ( source == 4) then 
        triggerServerEvent ( 'car4', localPlayer ) 
        end 
    end 
) 
addEventHandler ( 'onClientGUIClick', resourceRoot, function( ) 
    if ( source == 5]) then 
        triggerServerEvent ( 'car5', localPlayer ) 
        end 
    end 
) 
addEventHandler ( 'onClientGUIClick', resourceRoot, function( ) 
    if ( source == 6) then 
        triggerServerEvent ( 'car6', localPlayer ) 
        end 
    end 
) 
addEventHandler ( 'onClientGUIClick', resourceRoot, function( ) 
    if ( source == 7) then 
        triggerServerEvent ( 'car7', localPlayer ) 
        end 
    end 
) 
  
local marker = createMarker(x,y,z ) 
addEventHandler('onClientMarkerHit',marker,function (plr) 
    if plr == localPlayer then 
        guiSetVisible(GUIEditor.button,true) 
        end 
    end 
) 

Server

  
local vehicle = {} 
addEvent( 'car', true ) 
addEventHandler( 'car1', root,function() 
    local x, y, z = getElementPosition ( source ) 
        if isElement(vehicle[source]) then destroyElement(vehicle[source]) vehicle[source] = nil end 
            vehicle[source] = createVehicle ( 431, x, y, z + 10 ) 
                outputChatBox ( "Car Spwan!", source) 
    end 
) 
  
local vehicle = {} 
addEvent( 'car2', true ) 
addEventHandler( 'car', root,function() 
    local x, y, z = getElementPosition ( source ) 
        if isElement(vehicle[source]) then destroyElement(vehicle[source]) vehicle[source] = nil end 
            vehicle[source] = createVehicle ( 432, x, y, z + 10 ) 
                outputChatBox ( "Car Spwan!", source) 
    end 
) 
  
local vehicle = {} 
addEvent( 'car3', true ) 
addEventHandler( 'car', root,function() 
    local x, y, z = getElementPosition ( source ) 
        if isElement(vehicle[source]) then destroyElement(vehicle[source]) vehicle[source] = nil end 
            vehicle[source] = createVehicle ( 434, x, y, z + 10 ) 
                outputChatBox ( "Car Spwan!", source) 
    end 
) 
  
local vehicle = {} 
addEvent( 'car4', true ) 
addEventHandler( 'car', root,function() 
    local x, y, z = getElementPosition ( source ) 
        if isElement(vehicle[source]) then destroyElement(vehicle[source]) vehicle[source] = nil end 
            vehicle[source] = createVehicle ( 421, x, y, z + 10 ) 
                outputChatBox ( "Car Spwan!", source) 
    end 
) 
  
local vehicle = {} 
addEvent( 'car5', true ) 
addEventHandler( 'car', root,function() 
    local x, y, z = getElementPosition ( source ) 
        if isElement(vehicle[source]) then destroyElement(vehicle[source]) vehicle[source] = nil end 
            vehicle[source] = createVehicle ( 132, x, y, z + 10 ) 
                outputChatBox ( "Car Spwan!", source) 
    end 
) 
  
local vehicle = {} 
addEvent( 'car6', true ) 
addEventHandler( 'car', root,function() 
    local x, y, z = getElementPosition ( source ) 
        if isElement(vehicle[source]) then destroyElement(vehicle[source]) vehicle[source] = nil end 
            vehicle[source] = createVehicle ( 232, x, y, z + 10 ) 
                outputChatBox ( "Car Spwan!", source) 
    end 
) 
  
local vehicle = {} 
addEvent( 'car7', true ) 
addEventHandler( 'car', root,function() 
    local x, y, z = getElementPosition ( source ) 
        if isElement(vehicle[source]) then destroyElement(vehicle[source]) vehicle[source] = nil end 
            vehicle[source] = createVehicle ( 442, x, y, z + 10 ) 
                outputChatBox ( "Car Spwan!", source) 
    end 
) 

  • Moderators
Posted
repir this code

Come on slaves ! We can help this nice gentleman ! :roll:

Haha, you are really funny. You made my day thanks :lol:

Posted

Look at the code again and you'll find the most obvious issues in it, first one is in the server where you define:

local vehicle = {} 

7 times, data variables should only be defined once.

The next issue is the usage of source on the server which sometimes passes the wrong player from the client, use "client" instead.

Issue 3, mixing of the event handlers both on server and client, why not write:

addEvent( 'car5', true ) 
addEventHandler( 'car5', root,function() 
  

instead of:

addEvent( 'car5', true ) 
addEventHandler( 'car', root,function() 
  

And most hilarious parts, why are you creating the same function 7 times, it only need to be created once with different arguments, applies both for client and server btw. There you go ;)

Posted
I dont have server now

This is the worst lie that you can ever write!

You can start your own server by using the server files provided by MTA:SA.

MTA\server\MTA Server.exe 

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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