Jump to content

wesleywillems17

Members
  • Content Count

    106
  • Joined

  • Last visited

Posts posted by wesleywillems17

  1. I downloaded a other login system resource from the community but still i get the error.

    So it has nothing to do with the script that i placed in the topic.

    Where can i look to find the bug? the debug doesn't give me a resource name.

  2. Hi all,

     

    Today i updated my MTA from 1.4.3 to 1.5.3

    I have copied all my resources from my older server to my new server but i have a problem.

    Everytime somebody joins my server then i get this error: ERROR: Client (****) triggered serverside event onLoadedAtClient, but event is not added serverside

    But there is no onLoadedAtClient -,-

    Can somebody tell me how to fix this?

     

    Login-system resource:

    Client.lua

    local infoLabelText = "Welcome to SARS:RPG\n\nYou must have a account to have access to SARS:RPG\nIf you don't have a account then feel free to create one.\nAs a guest you can only play for 30 minutes and you can't buy anything!\nFollow the rules and have a nice day!"
    local usernameText = "Username:"
    local passwordText = "Password:"
    local registerButtonText = "Create a account"
    local loginButtonText = "Login"
    local loginWindowText = "SARS:RPG 1.0"
    
    showChat(false)
    showCursor(true)
    toggleAllControls(false)
    setPlayerHudComponentVisible ( "all", false )
    setCameraMatrix(1855.80, -1469.50, 49.09, 1786.30, -1417.69, 94.69)
    local screenW, screenH = guiGetScreenSize()
    loginWindow = guiCreateWindow(screenW/2-648/2, screenH/2-303/2, 648, 303, loginWindowText, false)
    guiWindowSetMovable(loginWindow, false)
    guiWindowSetSizable(loginWindow, false)
    infoLabel = guiCreateLabel(0.01, 0.11, 0.97, 0.33, infoLabelText, true, loginWindow)
    guiSetFont(infoLabel, "default-bold-small")
    guiLabelSetHorizontalAlign(infoLabel, "center", false)
    guiLabelSetVerticalAlign(infoLabel, "center")
    usernameLabel = guiCreateLabel(0.02, 0.48, 0.25, 0.13, usernameText, true, loginWindow)
    guiSetFont(usernameLabel, "default-bold-small")
    guiLabelSetHorizontalAlign(usernameLabel, "right", false)
    guiLabelSetVerticalAlign(usernameLabel, "center")
    usernameInput = guiCreateEdit(0.28, 0.50, 0.71, 0.10, getPlayerName(localPlayer), true, loginWindow)
    guiEditSetMaxLength(usernameInput, 21)
    passwordLabel = guiCreateLabel(0.02, 0.63, 0.25, 0.13, passwordText, true, loginWindow)
    guiSetFont(passwordLabel, "default-bold-small")
    guiLabelSetHorizontalAlign(passwordLabel, "right", false)
    guiLabelSetVerticalAlign(passwordLabel, "center")
    passwordInput = guiCreateEdit(0.28, 0.64, 0.71, 0.10, "", true, loginWindow)
    guiEditSetMasked(passwordInput, true)
    guiEditSetMaxLength(passwordInput, 32)
    registerButton = guiCreateButton(0.02, 0.81, 0.43, 0.13, registerButtonText, true, loginWindow)
    guiSetFont(registerButton, "default-bold-small")
    guiSetProperty(registerButton, "NormalTextColour", "FFFFFFFF")
    loginButton = guiCreateButton(0.46, 0.81, 0.52, 0.13, loginButtonText, true, loginWindow)
    guiSetFont(loginButton, "default-bold-small")
    guiSetProperty(loginButton, "NormalTextColour", "FFFFFFFF")
    
    function buttonClick()
        if source == registerButton then
            if #guiGetText(usernameInput) < 5 then
                guiSetText(infoLabel,"Your username needs to be at least 5 characters long.")
    			return
            end
    		if #guiGetText(passwordInput) < 5 then
    			guiSetText(infoLabel,"Your password needs to be at least 5 characters long.")
    			return
    		end
    		triggerServerEvent("registerServer",localPlayer,guiGetText(usernameInput),guiGetText(passwordInput))
    	elseif source == loginButton then
    		triggerServerEvent("loginServer",localPlayer,guiGetText(usernameInput),guiGetText(passwordInput))
    	end
    end
    addEventHandler("onClientGUIClick",root,buttonClick)
    
    addEvent("clientResponse",true)
    function onResponse(n)
    	if n == 3 then
    		destroyElement(loginWindow)
    		showCursor(false)
    		toggleAllControls(true)
    		return
    	elseif n == 2 then
    		guiSetText(passwordInput,"")
    		guiLabelSetColor(passwordLabel, 255, 0, 0)
    	elseif n == 1 then
    		guiSetProperty(registerButton, "NormalTextColour", "FFFF0000")
    	elseif n == 4 or n == 5 then
    		guiSetProperty(loginButton, "NormalTextColour", "FFFF0000")
    	end
    	responseText = {
    		[1] = "There is no account with this username.\nClick on 'Create a account' to make a new account.",
    		[2] = "Your password didn't match with the username.\nPlease check your password and try again.",
    		[4] = "This username has already been taked, please login or use a other username.",
    		[5] = "congratulations!\nYou can now login with your new account!"
    	}
    	guiSetText(infoLabel,responseText[n])
    end
    addEventHandler("clientResponse",root,onResponse)
    
    function playSoundOnReg ()
         playSound("sound/reg.mp3")
    end
    addEvent( "playSound", true )
    addEventHandler( "playSound", root, playSoundOnReg )

    Server.lua:

    addEvent("loginServer",true)
    addEvent("registerServer",true)
    function loginProcess(username,password)
    	if not getAccount(username) then
    		triggerClientEvent(source,"clientResponse",source,1)
    		return
    	end
    	if not getAccount(username,password) then
    		triggerClientEvent(source,"clientResponse",source,2)
    		return
    	end
    	logIn(source,getAccount(username),password)
    	showChat(source, true)
    	setCameraTarget(source, nil)
    	setElementFrozen ( source, false )
    	setPlayerHudComponentVisible ( source, "all", true )
    	triggerClientEvent(source,"clientResponse",source,3)
    end
    
    function registerProcess(username,password)
    	if getAccount(username) then
    		triggerClientEvent(source,"clientResponse",source,4)
    		return
    	end
    	addAccount(username,password)
    	givePlayerMoney(source,50000)
    	setElementPosition ( source, 1481.14, -1770.90, 18.79 )
    	outputChatBox("As a newcomer you received $50,000", source, 255, 0, 0, true)
        triggerClientEvent ( source, "playSound", source )
    	triggerClientEvent(source,"clientResponse",source,5)
    end
    
    function onLogout ()
    	cancelEvent ()
    	outputChatBox("INFO: Function disabled", source, 255, 0, 0, true)
    	outputChatBox("INFO: Press ESC and then use 'Disconnect'", source, 255, 0, 0, true)
    end
    addEventHandler ("onPlayerLogout", root, onLogout)
    
    addEventHandler("loginServer",root,loginProcess)
    addEventHandler("registerServer",root,registerProcess)

     

  3. Hi all,

     

    I have downloaded a car shop resource from the community.

    I'm trying to add a sell button to sell a purchased vehicle but i have no experience with executeSQLQuery. :(

     

    Can somebody help me or explain to me how i could add a sell button to the panel?

     

    Client-side:

    dealerwdw = guiCreateWindow(0.19, 0.19, 0.57, 0.70, "", true)
    	guiWindowSetSizable(dealerwdw, false)
    	guiSetVisible(dealerwdw, false)
    dealerwdwgrid = guiCreateGridList(0.02, 0.05, 0.97, 0.83, true, dealerwdw)
    	guiGridListAddColumn(dealerwdwgrid, "Car", 0.5)
    	guiGridListAddColumn(dealerwdwgrid, "Price", 0.5)
    dealerwdwclosebtn = guiCreateButton(0.01, 0.88, 0.34, 0.09, "Close", true, dealerwdw)
    	guiSetProperty(dealerwdwclosebtn, "NormalTextColour", "FFAAAAAA")
    dealerwdwbuybtn = guiCreateButton(0.65, 0.88, 0.34, 0.09, "Buy", true, dealerwdw)
    	guiSetProperty(dealerwdwbuybtn, "NormalTextColour", "FFAAAAAA")
    
    function open_dealer_panel ()
    	if guiGetVisible(dealerwdw) == false then
    		guiSetVisible(dealerwdw, true)
    		showCursor(true)
    	end
    end
    addEvent("open_dealer_wdw", true)
    addEventHandler("open_dealer_wdw", getRootElement(), open_dealer_panel)
    
    DealerVehicles = {
    
    	{"Admiral", 50000},
    	{"Comet", 1000000},
    	{"Infernus", 3000000},
    	{"Bullet", 1500000},
    	{"Sultan", 1000000},
    	{"Huntley", 750000},
    	{"Sabre", 1000000},
    	
    }
    
    function list_cars ()
    	guiGridListClear(dealerwdwgrid)
    	for i,v in ipairs(DealerVehicles) do
    		local row = guiGridListAddRow(dealerwdwgrid)
    		guiGridListSetItemText(dealerwdwgrid, row, 1, v[1], false, false)
    		guiGridListSetItemText(dealerwdwgrid, row, 2, v[2], false, false)
    	end
    end
    addEvent("list_dealer_cars", true)
    addEventHandler("list_dealer_cars", getRootElement(), list_cars)
    
    function dealer_panel_clicked ()
    	if source == dealerwdwclosebtn and guiGetVisible(dealerwdw) == true then guiSetVisible(dealerwdw, false) showCursor(false) guiGridListClear(dealerwdwgrid)
    	end
    end
    addEventHandler("onClientGUIClick", dealerwdw, dealer_panel_clicked)
    
    function dealer_panel_buy (player)
    	if source == dealerwdwbuybtn then
    		local row = guiGridListGetSelectedItem(dealerwdwgrid)
    		triggerServerEvent("buy_dealer_car", getLocalPlayer(), getLocalPlayer(), guiGridListGetItemText(dealerwdwgrid, row, 1), guiGridListGetItemText(dealerwdwgrid, row, 1), guiGridListGetItemText(dealerwdwgrid, row, 2))
    	end
    end
    addEventHandler("onClientGUIClick", dealerwdw, dealer_panel_buy)
    
    ----------------------------------------------
    --------------- Spawner Panel ----------------
    ----------------------------------------------
    
    spawncarwdw = guiCreateWindow(0.4, 0.3, 0.2, 0.4, "", true)
    	guiWindowSetSizable(spawncarwdw, false)
    	guiSetVisible(spawncarwdw, false)
    spawncarwdwgrid = guiCreateGridList(0.0, 0.07, 1.0, 0.8, true, spawncarwdw)
    	guiGridListAddColumn(spawncarwdwgrid, "Owned vehicles:", 0.90)
    spawncarwdwclosebtn = guiCreateButton(0.00, 0.89, 0.17, 0.09, "Close", true, spawncarwdw)
    spawncarwdrefwdw = guiCreateButton(0.20, 0.89, 0.20, 0.09, "Refresh", true, spawncarwdw)
    spawncarSellCar = guiCreateButton(0.40, 0.89, 0.20, 0.09, "SellCar", true, spawncarwdw)
    spawncarwdwspwnwdw = guiCreateButton(0.60, 0.89, 0.20, 0.09, "Spawn Car", true, spawncarwdw)
    spawncarwdwparkbtn = guiCreateButton(0.80, 0.89, 0.20, 0.09, "Park Car", true, spawncarwdw)
    
    function open_spawner_panel ()
    	if guiGetVisible(spawncarwdw) == false then
    		guiSetVisible(spawncarwdw, true)
    		showCursor(true)
    		guiGridListClear(spawncarwdwgrid) 
    		triggerServerEvent("list_owned_cars_S", getLocalPlayer(), getLocalPlayer())
    	elseif 
    		guiGetVisible(spawncarwdw) == true then
    		guiSetVisible(spawncarwdw, false)
    		showCursor(false)
    	end
    end
    addEvent("open_spawner_wdw", true)
    addEventHandler("open_spawner_wdw", getRootElement(), open_spawner_panel)
    
    function vehicle_spawner_panel ()
    	if source == spawncarwdwclosebtn and guiGetVisible(spawncarwdw) == true then guiSetVisible(spawncarwdw, false) showCursor(false) guiGridListClear(spawncarwdwgrid) end
    	if source == spawncarwdrefwdw then guiGridListClear(spawncarwdwgrid) triggerServerEvent("list_owned_cars_S", getLocalPlayer(), getLocalPlayer()) end
    	if source == spawncarSellCar then guiGridListClear(spawncarwdwgrid) triggerServerEvent("SellaCar", getLocalPlayer(), getLocalPlayer()) end
    	if source == spawncarwdwspwnwdw then 
    		local row = guiGridListGetSelectedItem(spawncarwdwgrid)
    		triggerServerEvent("spawn_dealer_car", getLocalPlayer(), getLocalPlayer(), guiGridListGetItemText(spawncarwdwgrid, row, 1)) 
    	end
    	if source == spawncarwdwparkbtn then triggerServerEvent("destroy_dealer_car", getLocalPlayer(), getLocalPlayer()) end
    end
    addEventHandler("onClientGUIClick", spawncarwdw, vehicle_spawner_panel)
    
    function list_cars_you_own (vehiclemodel,vehicleHealth)
    	local row = guiGridListAddRow(spawncarwdwgrid)
    	guiGridListSetItemText(spawncarwdwgrid, row, 1, tostring(vehiclemodel), false, false)
    	guiGridListSetItemText(spawncarwdwgrid, row, 2, tonumber(vehicleHealth), false, false)
    end
    addEvent("list_owned_cars", true)
    addEventHandler("list_owned_cars", getRootElement(), list_cars_you_own) 

    Server-side:

    function make_db ()
    	executeSQLQuery ("CREATE TABLE IF NOT EXISTS dealercars (id NUMERIC, owner TEXT, model NUMERIC, name TEXT, health NUMBERIC, paintjob NUMERIC, color NUMERIC, upgrades NUMERIC)") 
    end
    addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), make_db)
    
    local dealerMarker1 = createMarker(2131.75, -1148.138671875, 23.406946182251, "cylinder", 2, 0, 255, 0, 255)
    createBlipAttachedTo(dealerMarker1, 55, 2, 0, 0, 0, 0, 0, 300)
    
    function open_dealer_server (hitElement)
    	if source == dealerMarker1 then 
    		triggerClientEvent(hitElement, "open_dealer_wdw", root)
    		triggerClientEvent(hitElement, "list_dealer_cars", root)
    	end
    end
    addEventHandler("onMarkerHit", getRootElement(), open_dealer_server)
    
    function buy_car_from_dealer (owner,model,name,money)
    	if getPlayerMoney(owner) >= tonumber(money) then
    		local ID = executeSQLQuery("SELECT * FROM dealercars")
    		for i,v in ipairs(ID) do
    			carid = v.id
    		end
    		local account = getAccountName(getPlayerAccount(owner))
    		local modela = getVehicleModelFromName(model)
    		local carbought = executeSQLQuery("INSERT INTO dealercars(id,owner,model,name,health,paintjob,color,upgrades) VALUES(?,?,?,?,?,?,?,?)", carid, tostring(account), tonumber(modela), tostring(model), 1000, 0, 0, 0) 
    		takePlayerMoney(owner, money)
    		setElementData(owner, "gotCar", "no")
    		outputChatBox("Congratulations you've bought a "..model.." for "..money, owner, 0, 255, 0)
    	else
    		outputChatBox("You don't have enough money", owner, 255, 0, 0)
    	end
    end
    addEvent("buy_dealer_car", true)
    addEventHandler("buy_dealer_car", getRootElement(), buy_car_from_dealer)
    
    
    ----------------------------------------------
    --------------- Spawner Panel ----------------
    ----------------------------------------------
    function keybindpla ()
    	for i,v in ipairs(getElementsByType("player")) do
    		bindKey(v, "f2", "down", open_spawner_pla)
    		setElementData(v, "gotCar", "no")
    	end
    end
    addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), keybindpla)
    addEventHandler("onPlayerLogin", getRootElement(), keybindpla)
    
    
    function open_spawner_pla (source)
    	triggerClientEvent(source, "open_spawner_wdw", root)
    end
    
    function list_owned_cars_server (player)
    	local playerAcc = getAccountName(getPlayerAccount(player))
    	local carlmao = executeSQLQuery("SELECT * FROM dealercars WHERE owner=?", playerAcc)
    	for i,k in ipairs(carlmao) do
    		triggerClientEvent(player, "list_owned_cars", root, k.name, k.health)
    	end
    end
    addEvent("list_owned_cars_S", true)
    addEventHandler("list_owned_cars_S", getRootElement(), list_owned_cars_server)
    
    
    function SellCarFromList (player)
    	???
    end
    addEvent("SellaCar", true)
    addEventHandler("SellaCar", getRootElement(), SellCarFromList)
    
    function spawn_car_pleaseD (ownerName,carName)
    	if getElementData(ownerName, "gotCar") == "no" then
    		local gayowner = getAccountName(getPlayerAccount(ownerName))
    		local carModel = getVehicleModelFromName(carName)
    		local x,y,z = getElementPosition(ownerName)
    		OwnerVehicle = createVehicle(carModel, x, y, z)
    		setTimer(warpPedIntoVehicle, 50, 1, ownerName, OwnerVehicle)
    		setElementData(OwnerVehicle, "owner", tostring(gayowner))
    		setElementData(ownerName, "gotCar", "yes")
    		local carlma = executeSQLQuery("SELECT * FROM dealercars WHERE owner=?", gayowner)
    	else
    		outputChatBox("You don't own a car", ownerName, 255, 0, 0)
    	end
    end
    addEvent("spawn_dealer_car", true)
    addEventHandler("spawn_dealer_car", getRootElement(), spawn_car_pleaseD)
    
    function destroy_car_pleaseD (ownerName)
    	pedCar = getPedOccupiedVehicle(ownerName)
    	gayownerAcc = getAccountName(getPlayerAccount(ownerName))
    	if isPedInVehicle(ownerName) == true then
    		if getElementData(ownerName, "gotCar") == "yes" and getElementData(pedCar, "owner") == gayownerAcc then
    			CurrentCar = getPedOccupiedVehicle(ownerName)
    			destroyElement(CurrentCar)
    			setElementData(ownerName, "gotCar", "no")
    		else 
    			outputChatBox("You can't park a car you don't own", ownerName, 255, 0, 0)
    		end
    	else 
    		outputChatBox("You aren't in a vehicle", ownerName, 255, 0, 0)
    	end
    end
    addEvent("destroy_dealer_car", true)
    addEventHandler("destroy_dealer_car", getRootElement(), destroy_car_pleaseD)

     

  4. Hi all,

     

    I'm currently busy scripting a roleplay server.

    Does somebody know if it is possible to bring the map of GTA United to MTA?

    Can i import the DDF, TXD and COL map files to MTA?

     

    If so, has somebody experience with this?

  5. Hi all,

     

    I'm busy with a trucker job resource for my server.

    But i have a problem with hiding the marker and blip when the player get's out of the truck.

    The markers are created at the client-side but i have no idea how i could send the marker and blip to the server-side (to hide).

    Client-side:

    addEventHandler("onClientVehicleExit", root,
        function(thePlayer)
    		local Truck = getPedOccupiedVehicle ( thePlayer )
    		if Truck and getElementModel(Truck) == 403 then
    		
    		end
        end
    )

    Server-side:

    function HideBlipMarker ( thePlayer )
    	setElementVisibleTo ( *Marker, thePlayer, false )
    	setElementVisibleTo ( *Blip, thePlayer, false )
    end

    Can somebody help me please :)

  6. Hi all,

     

    I'm busy with a drug transport script for my server.

    I'm trying to add a wanted level function to it so that if the player deliverd the van he will get 2 start of wanted level.

    But my problem is when i use setPlayerWantedLevel (thePlayer, 2) and the player has 4 start then the player will lose 2 start.

    Can somebody tell me how to fix this? :)

  7. Hi all,

     

    I have a problem with my drug transport script.

    I'm trying to make the marker not Visible once the player reach his destination.

    Everythibng works but i get a error everytime i hit the destination marker.

    How could i fix this?

    WARNING: [gameplay]\SRdrugDeliver\server.lua:14: Bad argument @ 'setElementVisibleTo' [Expected element at argument 2]

    function JobDoneLS(attackerLS)
    	if (attackerLS) and (attackerLS ~= source) then
    		setElementVisibleTo ( markerLS, attackerLS, false )
    		if isElement(CarLS) then 
    			destroyElement ( CarLS ) 
    		end 
    	end
    end
    addEventHandler( "onMarkerHit", markerLS, JobDoneLS )

     

  8. Hi,

    I have a problem with my car spawn script.

    Everything worked but when a player isn't in a team it says "Expected team at argument 1, got boolean".

    I know that it has something to do because i'm not in a team.

    What do i need to add to remove this bug/report?

    local vehicleTable = {}
    function SpawnRandomCopCar ()
    	team = getPlayerTeam(source)
    	if (getTeamName(team) == "Police officer") then
    		local CopCar = vehicleTable[source]
    		if CopCar then
    			if isElement( CopCar ) then
    				destroyElement( CopCar )
    			end
    			vehicleTable[source]= nil
    		end
    		x, y, z = SpawnCopCar ()
    		local CopCar = createVehicle ( 596, x, y, z, 0, 0, 180 )
    		warpPedIntoVehicle ( source, CopCar )
    		vehicleTable[source]= CopCar
    	else
    		outputChatBox ( "You must be a police officer to get a police car!", source, 255, 0, 0, true )
    	end
    end
    addEvent( "GiveCopCarFree", true )
    addEventHandler( "GiveCopCarFree", root, SpawnRandomCopCar )

     

  9. Thx it worked! :) Also everytime i join my server and start the debug it says: ERROR: freeroam\gui.lua:24 attempt to index local 'wnd' (a nil value)
     

    GUI.lua:24:

    function createWindow(wnd, rebuild)
    	if wnd.element then
    		if rebuild then
    			destroyElement(wnd.element)
    		else
    			guiSetVisible(wnd.element, true)
    			guiBringToFront(wnd.element)
    			g_openedWindows[wnd] = true
    			if wnd.oncreate then
    				wnd.oncreate()
    			end
    			return
    		end
    	end
    	
    	_planWindow(wnd)
    	_buildWindow(wnd)
    end

    I'm not a pro scripter but i'm still busy learning it but i have really no idea what i need to edit/remove here. :P

  10. Hi everybody,

     

    I'm creating a verhicle spawner for my police job but i have a problem.

    The script won't load and debug says: ERROR: SRpolice/vehicleC.lua:19 Stack overflow

    vehicleC.lua:

    local VehicleMarkerP = createMarker ( 1579.60, -1635.33, 12.56, "cylinder", 1, 0, 0, 255, 255 )
    
    local cars =
    {
        { 1552.50, -1606.20, 13.19 };
        { 1556.70, -1606.20, 13.19 };
        { 1560.90, -1606.20, 13.19 };
        { 1565.09, -1606.20, 13.19 };
        { 1569.29, -1606.20, 13.19 };
        { 1573.50, -1606.20, 13.19 };
        { 1577.70, -1606.20, 13.19 };
        { 1581.90, -1606.20, 13.19 };
        { 1586.09, -1606.20, 13.19 };
        { 1590.29, -1606.20, 13.19 };
        { 1594.50, -1606.20, 13.19 };
    }
    	
    function SpawnCopCar ()
        return unpack ( cars [ math.random ( #cars ) ] )
    end
    
    giveVehicleGUI = guiCreateWindow(0.4, 0.45, 0.2, 0.1, "Want a free police car?", true)
    	guiSetVisible ( giveVehicleGUI, false )
    	guiWindowSetMovable ( giveVehicleGUI, false )
    	guiWindowSetSizable ( giveVehicleGUI, false )
    VehGUItext = guiCreateLabel(0.0, 0.0, 1.0, 1.0, "Press enter to get a free police vehicle.\nWalk out of the marker to quit this panel.", true, giveVehicleGUI)
    	guiLabelSetHorizontalAlign(VehGUItext, "center", false)
    	guiLabelSetVerticalAlign(VehGUItext,"center")
    
    function createVehicle ()
        x, y, z = SpawnCopCar ()
        local CopCar = createVehicle ( 596, x, y, z, 0, 0, 180 )
    	warpPedIntoVehicle ( source, CopCar )
    end
    addEvent("CreateVehicleCop", true)
    addEventHandler ( "CreateVehicleCop", root, createVehicle )
    
    function giveAVehicle( hitPlayer )
    	guiSetVisible ( giveVehicleGUI, true )
    	triggerServerEvent ( "CreateVehicleCop", hitPlayer )
    end
    addEventHandler ( "onClientMarkerHit", VehicleMarkerP, giveAVehicle )
    
    function QuitVehPanel ( leavingPlayer, matchingDimension )
    	guiSetVisible ( giveVehicleGUI, false )
    end
    addEventHandler ( "onClientMarkerLeave", VehicleMarkerP, QuitVehPanel )

    I'm busy working on it so it is a little bugy but how can i fix the stack overflow and what does it mean? :)

  11. Ow i didn't see that i used root in the triggerServerEvent. :P

    I have changed it to thePlayer in the client-side and in the server-side i added source.

    It worked, thx everybody!

  12. Hi everyone!

     

    I i'm busy with creating a police job resource for my server.

    But i have a problem with the police team.

    Everytime when i hit the job marker and try to join the police officer team i get this message in the debug:

    WARNING: [gameplay]\SRpolice\server.lua:6: Bad argument @ 'setPlayerTeam' [Expected player at argument 1, got root]

    Server.lua:

    Teame = createTeam("Police officer", 0, 255, 255)
    
    function takePoliceJob ()
        local teamP = getTeamFromName ( "Police officer" )
    	if teamP then
    		setPlayerTeam( source, teamP )
    		setElementModel( source, 280 )
    		giveWeapon ( source, 3, 1 )
    	end
    end
    addEvent( "takeJob", true )
    addEventHandler( "takeJob", root, takePoliceJob )

    Client.lua:

    function hitJobMarker (thePlayer)
       local theVehicle = getPedOccupiedVehicle ( thePlayer )
    	if theVehicle then
    		guiSetVisible ( PoliceGUI, false )
    	else
    		setCameraMatrix(1522.40, -1646.80, 30.39, 1549.59, -1672.09, 14.39)
    		guiSetVisible ( PoliceGUI, true )
    		showChat(false)
    		setPlayerHudComponentVisible ( "all", false )
    		bindKey ("enter","down",
    			function(enter, down)
    				guiSetVisible ( PoliceGUI, false )
    				setCameraTarget(thePlayer)
    				showChat(true)
    				setPlayerHudComponentVisible ( "all", true )
    				triggerServerEvent ( "takeJob", root )
    			end
    		)
       end
    end
    addEventHandler ( "onClientMarkerHit", JobMarker, hitJobMarker )

    Can somebody tell me what i'm doing wrong and tell me how to fix this problem? :)

    Greetings!

  13. Thx and i'm still busy with it so there are some bugs maybe and i'm learning it so its hard for me to make a script like this. (

    without any bugs).

    And that's a good idea.. xD i have really no idee why i was use the server-side to create the marker and destroy it).

    Normally i use the client-side (Really no idee why but that's how i learned it).

    Also sorry for my bad English :P

  14. Oow i thought you mean that part of the code :P

    local EndDesMarker = createMarker ( 2411.81, -1300.46, 23.62, "cylinder", 1, 255, 255, 0, 170 ) 
    EndDesBlip = createBlipAttachedTo ( EndDesMarker, 53 ) 
    setElementVisibleTo ( EndDesMarker, root, false ) 
    setElementVisibleTo ( EndDesBlip, root, false ) 
      
    local CarParks = 
    { 
        { 2415.27, -1238.13, 23.45 }; 
        { 2433.49, -1224.88, 24.74 }; 
    } 
      
    local CarTypes = 
    { 
        { 518 }; 
        { 457 }; 
    } 
      
    function unpackCarParks () 
        return unpack ( CarParks [ math.random ( #CarParks ) ] ) 
    end 
      
    function unpackCarTypes () 
        return unpack ( CarTypes [ math.random ( #CarTypes ) ] ) 
    end 
      
    function CreateCar () 
        x, y, z = unpackCarParks () 
        Veh = unpackCarTypes () 
        CarJacker = createVehicle ( Veh, x, y, z, 0, 0, 9 ) 
        CarJackerBlip = createBlipAttachedTo ( CarJacker, 55 ) 
    end 
    addEventHandler ( "onResourceStart", root, CreateCar ) 
      
    function enterVehicle () 
        setElementVisibleTo ( EndDesMarker, root, true ) 
        setElementVisibleTo ( EndDesBlip, root, true ) 
    end 
    addEventHandler ( "onVehicleEnter", root, enterVehicle ) 
      
    function DestroyStuff () 
        setElementVisibleTo ( EndDesMarker, root, false ) 
        setElementVisibleTo ( EndDesBlip, root, false ) 
    end 
    addEventHandler ( "onVehicleExit", root, DestroyStuff ) 
      
    function JobDone ( hitElement, matchingDimension ) 
        if hitElement then 
            local elementType = getElementType( hitElement ) 
            if elementType == "player" then 
                if isElement( EndDesMarker ) then 
                    destroyElement( EndDesMarker ) 
                end 
                if isElement( EndDesBlip ) then 
                    destroyElement( EndDesBlip ) 
                end 
                if isElement( CarJacker ) then 
                    destroyElement( CarJacker ) 
                end 
                if isElement( CarJackerBlip ) then 
                    destroyElement( CarJackerBlip ) 
                end 
                money = math.random ( 2000, 5000 ) 
                givePlayerMoney ( hitElement, money ) 
                outputChatBox ( "Got job! You received $" ..money, hitElement ) 
            end 
        end 
    end 
    addEventHandler( "onMarkerHit", EndDesMarker, JobDone ) 
      
    addEventHandler ( "onResourceStop", root,  
        function () 
            if isElement( CarJacker ) then 
                destroyElement( CarJacker ) 
            end 
            if isElement( CarJackerBlip ) then 
                destroyElement( CarJackerBlip ) 
            end 
        end  
    ) 
    

  15. Sure!

    function JobDone ( hitElement, matchingDimension ) 
        if hitElement then 
            local elementType = getElementType( hitElement ) 
            if elementType == "player" then 
                if isElement( EndDesMarker ) then 
                    destroyElement( EndDesMarker ) 
                end 
                if isElement( EndDesBlip ) then 
                    destroyElement( EndDesBlip ) 
                end 
                if isElement( CarJacker ) then 
                    destroyElement( CarJacker ) 
                end 
                if isElement( CarJackerBlip ) then 
                    destroyElement( CarJackerBlip ) 
                end 
                money = math.random ( 2000, 5000 ) 
                givePlayerMoney ( hitElement, money ) 
                outputChatBox ( "Got job! You received $" ..money, hitElement ) 
            end 
        end 
    end 
    addEventHandler( "onMarkerHit", EndDesMarker, JobDone ) 
    

×
×
  • Create New...