undefined Posted June 2, 2014 Share Posted June 2, 2014 Hi Guys! Error: Where is the problem? local allMissions = { [1]={ ["name"] = "Mission I", ["info"] = "Text" }, [2]={ ["name"] = "Mission II", ["info"] = "Text" } } addEventHandler("onClientResourceStart", resourceRoot, function() missionWindow = guiCreateWindow(238, 190, 402, 264, "Mission Panel", false) guiSetVisible(missionWindow, false) guiWindowSetSizable(missionWindow, false) guiSetAlpha(missionWindow, 0.65) nameGrid = guiCreateGridList(10, 26, 122, 228, false, missionWindow) guiGridListAddColumn(nameGrid, "Missions", 0.7) local mrow = guiGridListAddRow(nameGrid) guiGridListSetItemText(nameGrid,mrow,1,"Missions",true,false) myFont = guiCreateFont( "font.otf", 12 ) infoGrid = guiCreateGridList(142, 26, 250, 180, false, missionWindow) infoLab = guiCreateLabel(10, 40, 230, 130, "", false, infoGrid) guiSetFont(infoLab, "default-bold-small") guiLabelSetHorizontalAlign(infoLab, "center", true) yesnoGrid = guiCreateGridList(0, 10, 230, 120, false, infoLab) guiSetVisible(yesnoGrid, false) yesnoLab = guiCreateLabel(10, 10, 210, 66, "Devam etmek istiyor musun?", false, yesnoGrid) guiSetFont(yesnoLab, myFont) guiLabelSetHorizontalAlign(yesnoLab, "center", true) guiLabelSetVerticalAlign(yesnoLab, "center") yes = guiCreateButton(20, 86, 66, 24, "Evet", false, yesnoGrid) guiSetFont(yes, "default-bold-small") no = guiCreateButton(144, 86, 66, 24, "Hayır", false, yesnoGrid) guiSetFont(no, "default-bold-small") infoNameLab = guiCreateLabel(10, 9, 230, 21, "", false, infoGrid) guiSetFont(infoNameLab, myFont) guiLabelSetHorizontalAlign(infoNameLab, "center", true) for i=1,#allMissions do local row = guiGridListAddRow(nameGrid) guiGridListSetItemText(nameGrid,row,1,allMissions[i].name,false,false) end addEventHandler("onClientGUIClick",nameGrid,function() local row = guiGridListGetSelectedItem(nameGrid) if(row > 0) then local name = guiGridListGetItemText(nameGrid,row,1) guiSetText(infoLab,allMissions[row].info) guiSetText(infoNameLab,allMissions[row].name) end end, false) take = guiCreateButton(142, 223, 98, 31, "Görevi Al", false, missionWindow) guiSetFont(take, "default-bold-small") close = guiCreateButton(294, 223, 98, 31, "Kapat", false, missionWindow) guiSetFont(close, "default-bold-small") end ) function select() if (source == close) then guiSetVisible(missionWindow,false) guiSetVisible (yesnoGrid, false) showCursor(false) elseif (source == take) then guiSetVisible (yesnoGrid, true) elseif (source == no) then guiSetVisible (yesnoGrid, false) elseif (source == yes) then guiSetVisible (missionWindow, false) guiSetVisible (yesnoGrid, false) showCursor(false) local row = guiGridListGetSelectedItem(nameGrid) if (allMissions[row]) then triggerClientEvent(allMissions[row]["name"], getRootElement()) end end end addEventHandler("onClientGUIClick", root, select) function open() if (guiGetVisible (missionWindow) == true) then guiSetVisible(missionWindow, false) showCursor(false) elseif (guiGetVisible (missionWindow) == false) then guiSetVisible(missionWindow, true) showCursor(true) end end bindKey ("R", "down", open) Link to comment
Den. Posted June 2, 2014 Share Posted June 2, 2014 triggerClientEvent is obviously a server-side function only, therefore; You cannot use it client-side. Replace it with triggerEvent if you want to trigger the event client-side, or triggerServerEvent if you want to trigger that event server-side. If you get errors similar to that in the future, you should check the wiki for the function you're using. Link to comment
undefined Posted June 2, 2014 Author Share Posted June 2, 2014 Oh, I did not notice. But i have a new problem; It's not spawn the player or create marker. It's not give error and warning on debugscript.ü Where is the problem? Client-Side local allMissions = { [1]={ ["name"] = "Mission I", ["info"] = "Text" }, [2]={ ["name"] = "Mission II", ["info"] = "Text" } } addEventHandler("onClientResourceStart", resourceRoot, function() missionWindow = guiCreateWindow(238, 190, 402, 264, "Mission Panel", false) guiSetVisible(missionWindow, false) guiWindowSetSizable(missionWindow, false) guiSetAlpha(missionWindow, 0.65) nameGrid = guiCreateGridList(10, 26, 122, 228, false, missionWindow) guiGridListAddColumn(nameGrid, "Missions", 0.7) local mrow = guiGridListAddRow(nameGrid) guiGridListSetItemText(nameGrid,mrow,1,"Missions",true,false) myFont = guiCreateFont( "font.otf", 12 ) infoGrid = guiCreateGridList(142, 26, 250, 180, false, missionWindow) infoLab = guiCreateLabel(10, 40, 230, 130, "", false, infoGrid) guiSetFont(infoLab, "default-bold-small") guiLabelSetHorizontalAlign(infoLab, "center", true) yesnoGrid = guiCreateGridList(0, 10, 230, 120, false, infoLab) guiSetVisible(yesnoGrid, false) yesnoLab = guiCreateLabel(10, 10, 210, 66, "Devam etmek istiyor musun?", false, yesnoGrid) guiSetFont(yesnoLab, myFont) guiLabelSetHorizontalAlign(yesnoLab, "center", true) guiLabelSetVerticalAlign(yesnoLab, "center") yes = guiCreateButton(20, 86, 66, 24, "Evet", false, yesnoGrid) guiSetFont(yes, "default-bold-small") no = guiCreateButton(144, 86, 66, 24, "Hayır", false, yesnoGrid) guiSetFont(no, "default-bold-small") infoNameLab = guiCreateLabel(10, 9, 230, 21, "", false, infoGrid) guiSetFont(infoNameLab, myFont) guiLabelSetHorizontalAlign(infoNameLab, "center", true) for i=1,#allMissions do local row = guiGridListAddRow(nameGrid) guiGridListSetItemText(nameGrid,row,1,allMissions[i].name,false,false) end addEventHandler("onClientGUIClick",nameGrid,function() local row = guiGridListGetSelectedItem(nameGrid) if(row > 0) then local name = guiGridListGetItemText(nameGrid,row,1) guiSetText(infoLab,allMissions[row].info) guiSetText(infoNameLab,allMissions[row].name) end end, false) take = guiCreateButton(142, 223, 98, 31, "Görevi Al", false, missionWindow) guiSetFont(take, "default-bold-small") close = guiCreateButton(294, 223, 98, 31, "Kapat", false, missionWindow) guiSetFont(close, "default-bold-small") end ) function select() if (source == close) then guiSetVisible(missionWindow,false) guiSetVisible (yesnoGrid, false) showCursor(false) elseif (source == take) then guiSetVisible (yesnoGrid, true) elseif (source == no) then guiSetVisible (yesnoGrid, false) elseif (source == yes) then guiSetVisible (missionWindow, false) guiSetVisible (yesnoGrid, false) showCursor(false) local row = guiGridListGetSelectedItem(nameGrid) if (allMissions[row]) then triggerServerEvent(allMissions[row]["name"], localPlayer) setElementData( source, "gorev", source ) end end end addEventHandler("onClientGUIClick", root, select) function open() if (guiGetVisible (missionWindow) == true) then guiSetVisible(missionWindow, false) showCursor(false) elseif (guiGetVisible (missionWindow) == false) then guiSetVisible(missionWindow, true) showCursor(true) end end bindKey ("R", "down", open) Server-Side-Part function missionVehicle( source ) setTimer(function( source ) if ( not isElement( source ) ) then return end if ( isElement( blip ) ) then destroyElement( blip ) blip = nil end if ( isElement( checkpoint ) ) then destroyElement( checkpoint ) checkpoint = nil end local playerAccount = getPlayerAccount( source ) local isAccount = ( playerAccount and not isGuestAccount( playerAccount ) ) and true or false if ( isAccount ) and ( not getAccountData( playerAccount, "deamuil" ) ) then spawnPlayer( source, -1335, 500, 11.2, 180 ) local pSkin_ = ( getElementData( player, "Skin" ) or math.random(312) ) repeat until setElementModel(player,pSkin_) --triggerClientEvent(source, "gorevinfo1" , getRootElement()) setPedAnimation( source, "ped" , "WALK_gang1" ) setTimer( function () setPedAnimation(source,nil,nil) setElementFrozen ( source, true) end, 5000, 1) setCameraMatrix( source, -1340.1, 488.76, 14.9, 0, 4000, 0, 0 ) setTimer ( function () setCameraTarget( source, source ) setElementFrozen ( source, false ) end, 17500, 1 ) fadeCamera( source, true, 5 ) checkpoint = createMarker( 0, 0, 0, "checkpoint", 1, 20, 20, 20, 20, source ) attachElements( checkpoint, source, 0, 0, 0 ) end end, 100, 1, source ) end addEvent( "Mission I",true ) addEventHandler( "Mission I", getRootElement() ,missionVehicle ) And im not have the "deamuil" account... Link to comment
KaduRo Posted June 2, 2014 Share Posted June 2, 2014 I can see you have many bugs and also i still can't help you is blip defined ? getAccountData(playerAccount, "deamuil" ) -- No setAccountData ?? getElementData(player , "Skin") -- is there setElementData("Skin") ? Link to comment
undefined Posted June 2, 2014 Author Share Posted June 2, 2014 I can see you have many bugs and also i still can't help you is blip defined ? getAccountData(playerAccount, "deamuil" ) -- No setAccountData ?? getElementData(player , "Skin") -- is there setElementData("Skin") ? getAccountData(playerAccount, "deamuil" ) -- No setAccountData ?? It's getAccountData. It's true! getElementData(player , "Skin") -- is there setElementData("Skin") ? It's true. Look at the code; addEventHandler( "onPlayerWasted", root, function( totalAmmo, killer, killerWeapon, bodypart, stealth ) local playerAccount = getPlayerAccount( source ) local isAccount = ( playerAccount and not isGuestAccount( playerAccount ) ) and true or false local pSkin = getElementModel(source) setElementData( source, "Skin", pSkin ) if ( getElementData(source, "gorev" ) ) and ( not getAccountData( playerAccount, "deamuil" ) ) then missionVehicle( source ) removeElementData(source,"gorev") removeElementData(source,"trailerAttach") return end end ) local pSkin_ = ( getElementData( player, "Skin" ) or math.random(312) ) repeat until setElementModel(player,pSkin_) Help pls! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now