crazyde21 Posted September 20, 2013 Share Posted September 20, 2013 How can I modify? I want the players to accept the task, and then create a marker, When players enter the marker to complete the task. But my script, I have to take the task, but others can do! client --[[------------------------------------------------- Notes: > This code is using a relative image filepath. This will only work as long as the location it is from always exists, and the resource it is part of is running. To ensure it does not break, it is highly encouraged to move images into your local resource and reference them there. --]]------------------------------------------------- mission = { gridlist = {}, window = {}, staticimage = {}, button = {}, label = {} } mission.window[1] = guiCreateWindow(198, 77, 385, 516, "mission", false) guiWindowSetSizable(mission.window[1], false) guiSetAlpha(mission.window[1], 1.00) mission.staticimage[1] = guiCreateStaticImage(9, 22, 366, 484, ":olsystem/images/palette.png", false, mission.window[1]) mission.gridlist[1] = guiCreateGridList(0, 0, 177, 485, false, mission.staticimage[1]) guiGridListAddColumn(mission.gridlist[1], "mission list", 0.4) guiGridListAddColumn(mission.gridlist[1], "Status", 0.4) guiGridListAddRow(mission.gridlist[1]) guiGridListSetItemText(mission.gridlist[1], 0, 1, "Police", false, false) guiGridListSetItemText(mission.gridlist[1], 0, 2, "X", false, false) mission.gridlist[2] = guiCreateGridList(178, 0, 188, 484, false, mission.staticimage[1]) guiGridListAddColumn(mission.gridlist[2], " ", 0.9) mission.label[1] = guiCreateLabel(43, 4, 88, 17, "", false, mission.gridlist[2]) guiLabelSetHorizontalAlign(mission.label[1], "center", false) mission.label[2] = guiCreateLabel(2, 30, 186, 322, "", false, mission.gridlist[2]) mission.button[1] = guiCreateButton(107, 437, 81, 47, "Close", false, mission.gridlist[2]) guiSetProperty(mission.button[1], "NormalTextColour", "FFFFFFFF") mission.button[2] = guiCreateButton(12, 437, 81, 47, "accept", false, mission.gridlist[2]) guiSetProperty(mission.button[2], "NormalTextColour", "FFFFFFFF") guiSetVisible(mission.window[1],false) cjped=createPed ( 147, 2514.76758,-1673.75623,13.67720 ,80) setElementFrozen ( cjped, true ) function addLabelOnClick ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) if state =="down" then if ( clickedElement )==cjped then guiSetVisible(mission.window[1],true) end end end addEventHandler("onClientGUIClick", getRootElement(), function () local row = guiGridListGetItemText ( mission.gridlist[1], guiGridListGetSelectedItem ( mission.gridlist[1] ), 1 ) if row == "Police" then guiSetText ( mission.label[1], "Police" ) guiSetText ( mission.label[2], "Brian:\nFriends,I need your help\nLack of material \nsecurity zone, can you help me\nPolice look to see." ) end end ) addEventHandler ( "onClientClick", getRootElement(), addLabelOnClick ) bindKey ("m", "down", function() showCursor( not isCursorShowing() ) end) function cancelPedDamage ( attacker ) cancelEvent() end addEventHandler ( "onClientPedDamage", cjped, cancelPedDamage ) addEventHandler("onClientGUIClick", mission.button[1],function() guiSetText ( mission.label[1], "" ) guiSetText ( mission.label[2], "" ) guiSetVisible(mission.window[1],false) showCursor(false) end ) addEventHandler("onClientGUIClick", mission.button[2], function() local player=getLocalPlayer() local row = guiGridListGetItemText ( mission.gridlist[1], guiGridListGetSelectedItem ( mission.gridlist[1] ), 1 ) if row == "Police" then local name=getPlayerName(getLocalPlayer()) triggerServerEvent("jjrw",getLocalPlayer(),name,player) end end ) addEvent("jjrwz",true) addEventHandler("jjrwz",getRootElement(), function(RW2) local name=getPlayerName(getLocalPlayer()) if tonumber(RW2)==0 then outputChatBox("You do not have to accept the mission!") end if tonumber(RW2)==1 then outputChatBox("mission completed!") triggerServerEvent("wcjjrw",getLocalPlayer(),name) end if tonumber(RW2)==2 then outputChatBox("You can not do this task!") end end ) server handler = mysql_connect( host, username, password, db ) addEvent("jjrw",true) addEventHandler("jjrw",getRootElement(), function(name) local result = mysql_query(handler, "SELECT RW2 FROM players WHERE Username='"..name.."'") for result,row in mysql_rows(result) do mysql_field_seek(result, 1) for k,RW2 in ipairs(row) do local field = mysql_fetch_field(result) if tonumber(RW2)== 2 then outputChatBox("* Before you have completed this task!",source,255,255,255,true) else mysql_query(handler,"UPDATE `players` SET RW2=1 WHERE`Username`= '"..name.."'") jjrw = createMarker (1553.51794,-1675.84668,15.19531, "cylinder", 1.5, 255, 255, 0, 170 ) outputChatBox("* You accept the".."police".."take!",source,255,255,255,true) function MarkerHit (thePlayer) local name=getPlayerName(thePlayer) triggerEvent("checkjjrw",thePlayer,name) end addEventHandler ( "onMarkerHit", jjrw, MarkerHit ) end end end end ) addEvent("checkjjrw",true) addEventHandler("checkjjrw",getRootElement(),function(name) local result = mysql_query(handler, "SELECT RW2 FROM players WHERE Username='"..name.."'") for result,row in mysql_rows(result) do mysql_field_seek(result, 1) for k,RW2 in ipairs(row) do triggerClientEvent("jjrwz",getRootElement(),RW2) destroyElement ( jjrw ) end end end ) addEvent("wcjjrw",true) addEventHandler("wcjjrw",getRootElement(),function(name) mysql_query(handler,"UPDATE `players` SET RW2=2 WHERE`Username`= '"..name.."'") mysql_query(handler,"UPDATE `players` SET Money=Money+500 WHERE`Username`= '"..name.."'") end ) this is use"Mysql"save mission! 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