WolfPire Posted February 22, 2012 Share Posted February 22, 2012 So hey guys, WolfPire here again! =) I wanna clarify that... Yes, i'm making a server =) And i'll need as much help as i can! So i got a little problem with my script (which is not complete). 1. The GUI appears from everyone even tho' its client 2. The GUI will just let me update rotations once when pressing the buttons 3. It will also set everyone's camera to the defined matrix (which should only do this to the hitElement) Here's the script: CLIENT Shop = createColSphere( -1658, 1211, 8, 2) function ShopF(theElement) setCameraMatrix( -1664, 1210, 22, 0, 0, 0, 0, 0) CarOfTheDay = createVehicle( math.random(400,611), -1655, 1209, 22 ) RX, RY, RZ = getElementRotation(CarOfTheDay) showCursor(true) if (getVehicleType" class="kw2">getVehicleType(CarOfTheDay) == "Automobile") then setVehicleColor( CarOfTheDay, math.random(0,255), math.random(0,255), math.random(0,255) ) showPlayerHudComponent("all", false) LeftB = guiCreateButton(342,684,176,57,"< Left",false) guiSetFont(LeftB,"default-bold-small") RightB = guiCreateButton(737,684,176,57,"Right >",false) guiSetFont(RightB,"default-bold-small") ExitB = guiCreateButton(539,714,174,26,"Exit",false) guiSetFont(ExitB,"default-bold-small") BuyB = guiCreateButton(539,689,174,26,"Buy",false) guiSetFont(BuyB,"default-bold-small") addEventHandler("onClientGUIClick",LeftB,LeftFEnter) addEventHandler("onClientGUIClick",RightB,RightFEnter) addEventHandler("onClientGUIClick",BuyB,BuyF,false) addEventHandler("onClientGUIClick",ExitB,ExitF,false) else destroyElement(CarOfTheDay) CarOfTheDay = createVehicle( math.random(400,611), -1655, 1209, 22 ) end end addEventHandler("onClientColShapeHit",Shop,ShopF) function ExitF() destroyElement(LeftB) destroyElement(RightB) destroyElement(ExitB) destroyElement(BuyB) destroyElement(CarOfTheDay) showPlayerHudComponent("all", true) setCameraTarget(localPlayer) showCursor(false) end function LeftFEnter() setElementRotation(CarOfTheDay, RX, RY, RZ + 10) end function RightFEnter() setElementRotation(CarOfTheDay, RX, RY, RZ - 10) end function BuyF() CW = guiCreateWindow(470,244,543,180,"Confirmation",false) CL = guiCreateLabel(2,47,545,20,"Are you sure you want to buy this car for $3.000?",false,CW) guiLabelSetColor(CL,0,255,0) guiLabelSetHorizontalAlign(CL,"center",false) guiSetFont(CL,"default-bold-small") YesB = guiCreateButton(59,115,159,39,"Yes",false,CW) NoB = guiCreateButton(322,115,159,39,"No",false,CW) addEventHandler("onClientGUIClick",NoB,NoF,false) addEventHandler("onClientGUIClick",YesB,YesF,false) end function NoF() destroyElement(CW) end function YesF() Model = getElementModel(CarOfTheDay) Up = getVehicleUpgrades ( CarOfTheDay ) triggerServerEvent("spawnCar",getRootElement(),localPlayer, Model) showCursor(false) end Server (I know it's wrong, but ill fix that later, what i wanna center on right now is the GUI problem) addEvent("spawnCar",true) addEventHandler("spawnCar",root, function(localPlayer, Model, Up) YourVehicle = createVehicle(getElementModel(Model), -1643, 1219, 7) addVehicleUpgrade(YourVehicle, Up) warpPedIntoVehicle(localPlayer, YourVehicle) end ) If you guys could please help me, it would be awesome! =) Link to comment
Castillo Posted February 22, 2012 Share Posted February 22, 2012 Shop = createColSphere( -1658, 1211, 8, 2) function ShopF(theElement) if (theElement ~= localPlayer) then return end -- If the player who hit the colshape isn't the client, cancel the function. setCameraMatrix( -1664, 1210, 22, 0, 0, 0, 0, 0) CarOfTheDay = createVehicle( math.random(400,611), -1655, 1209, 22 ) RX, RY, RZ = getElementRotation(CarOfTheDay) showCursor(true) if (getVehicleType(CarOfTheDay) == "Automobile") then setVehicleColor( CarOfTheDay, math.random(0,255), math.random(0,255), math.random(0,255) ) showPlayerHudComponent("all", false) LeftB = guiCreateButton(342,684,176,57,"< Left",false) guiSetFont(LeftB,"default-bold-small") RightB = guiCreateButton(737,684,176,57,"Right >",false) guiSetFont(RightB,"default-bold-small") ExitB = guiCreateButton(539,714,174,26,"Exit",false) guiSetFont(ExitB,"default-bold-small") BuyB = guiCreateButton(539,689,174,26,"Buy",false) guiSetFont(BuyB,"default-bold-small") addEventHandler("onClientGUIClick",LeftB,LeftFEnter) addEventHandler("onClientGUIClick",RightB,RightFEnter) addEventHandler("onClientGUIClick",BuyB,BuyF,false) addEventHandler("onClientGUIClick",ExitB,ExitF,false) else destroyElement(CarOfTheDay) CarOfTheDay = createVehicle( math.random(400,611), -1655, 1209, 22 ) end end addEventHandler("onClientColShapeHit",Shop,ShopF) function ExitF() destroyElement(LeftB) destroyElement(RightB) destroyElement(ExitB) destroyElement(BuyB) destroyElement(CarOfTheDay) showPlayerHudComponent("all", true) setCameraTarget(localPlayer) showCursor(false) end function LeftFEnter() setElementRotation(CarOfTheDay, RX, RY, RZ + 10) end function RightFEnter() setElementRotation(CarOfTheDay, RX, RY, RZ - 10) end function BuyF() CW = guiCreateWindow(470,244,543,180,"Confirmation",false) CL = guiCreateLabel(2,47,545,20,"Are you sure you want to buy this car for $3.000?",false,CW) guiLabelSetColor(CL,0,255,0) guiLabelSetHorizontalAlign(CL,"center",false) guiSetFont(CL,"default-bold-small") YesB = guiCreateButton(59,115,159,39,"Yes",false,CW) NoB = guiCreateButton(322,115,159,39,"No",false,CW) addEventHandler("onClientGUIClick",NoB,NoF,false) addEventHandler("onClientGUIClick",YesB,YesF,false) end function NoF() destroyElement(CW) end function YesF() Model = getElementModel(CarOfTheDay) Up = getVehicleUpgrades ( CarOfTheDay ) triggerServerEvent("spawnCar",getRootElement(),localPlayer, Model) showCursor(false) end Link to comment
WolfPire Posted February 22, 2012 Author Share Posted February 22, 2012 Shop = createColSphere( -1658, 1211, 8, 2) function ShopF(theElement) if (theElement ~= localPlayer) then return end -- If the player who hit the colshape isn't the client, cancel the function. setCameraMatrix( -1664, 1210, 22, 0, 0, 0, 0, 0) CarOfTheDay = createVehicle( math.random(400,611), -1655, 1209, 22 ) RX, RY, RZ = getElementRotation(CarOfTheDay) showCursor(true) if (getVehicleType(CarOfTheDay) == "Automobile") then setVehicleColor( CarOfTheDay, math.random(0,255), math.random(0,255), math.random(0,255) ) showPlayerHudComponent("all", false) LeftB = guiCreateButton(342,684,176,57,"< Left",false) guiSetFont(LeftB,"default-bold-small") RightB = guiCreateButton(737,684,176,57,"Right >",false) guiSetFont(RightB,"default-bold-small") ExitB = guiCreateButton(539,714,174,26,"Exit",false) guiSetFont(ExitB,"default-bold-small") BuyB = guiCreateButton(539,689,174,26,"Buy",false) guiSetFont(BuyB,"default-bold-small") addEventHandler("onClientGUIClick",LeftB,LeftFEnter) addEventHandler("onClientGUIClick",RightB,RightFEnter) addEventHandler("onClientGUIClick",BuyB,BuyF,false) addEventHandler("onClientGUIClick",ExitB,ExitF,false) else destroyElement(CarOfTheDay) CarOfTheDay = createVehicle( math.random(400,611), -1655, 1209, 22 ) end end addEventHandler("onClientColShapeHit",Shop,ShopF) function ExitF() destroyElement(LeftB) destroyElement(RightB) destroyElement(ExitB) destroyElement(BuyB) destroyElement(CarOfTheDay) showPlayerHudComponent("all", true) setCameraTarget(localPlayer) showCursor(false) end function LeftFEnter() setElementRotation(CarOfTheDay, RX, RY, RZ + 10) end function RightFEnter() setElementRotation(CarOfTheDay, RX, RY, RZ - 10) end function BuyF() CW = guiCreateWindow(470,244,543,180,"Confirmation",false) CL = guiCreateLabel(2,47,545,20,"Are you sure you want to buy this car for $3.000?",false,CW) guiLabelSetColor(CL,0,255,0) guiLabelSetHorizontalAlign(CL,"center",false) guiSetFont(CL,"default-bold-small") YesB = guiCreateButton(59,115,159,39,"Yes",false,CW) NoB = guiCreateButton(322,115,159,39,"No",false,CW) addEventHandler("onClientGUIClick",NoB,NoF,false) addEventHandler("onClientGUIClick",YesB,YesF,false) end function NoF() destroyElement(CW) end function YesF() Model = getElementModel(CarOfTheDay) Up = getVehicleUpgrades ( CarOfTheDay ) triggerServerEvent("spawnCar",getRootElement(),localPlayer, Model) showCursor(false) end excelent, Thanks... Now the other problem is that the Left and Right arrows will only let me rotate the car just 1 time.. and i don't know why >_< Link to comment
Kenix Posted February 22, 2012 Share Posted February 22, 2012 Shop = createColSphere( -1658, 1211, 8, 2) function ShopF(theElement) if (theElement ~= localPlayer) then return end -- If the player who hit the colshape isn't the client, cancel the function. setCameraMatrix( -1664, 1210, 22, 0, 0, 0, 0, 0) CarOfTheDay = createVehicle( math.random(400,611), -1655, 1209, 22 ) showCursor(true) if (getVehicleType" class="kw2">getVehicleType(CarOfTheDay) == "Automobile") then setVehicleColor( CarOfTheDay, math.random(0,255), math.random(0,255), math.random(0,255) ) showPlayerHudComponent("all", false) LeftB = guiCreateButton(342,684,176,57,"< Left",false) guiSetFont(LeftB,"default-bold-small") RightB = guiCreateButton(737,684,176,57,"Right >",false) guiSetFont(RightB,"default-bold-small") ExitB = guiCreateButton(539,714,174,26,"Exit",false) guiSetFont(ExitB,"default-bold-small") BuyB = guiCreateButton(539,689,174,26,"Buy",false) guiSetFont(BuyB,"default-bold-small") addEventHandler( "onClientGUIClick",LeftB,LeftFEnter,false ) addEventHandler( "onClientGUIClick",RightB,RightFEnter,false ) addEventHandler( "onClientGUIClick",BuyB,BuyF,false ) addEventHandler( "onClientGUIClick",ExitB,ExitF,false ) else destroyElement(CarOfTheDay) CarOfTheDay = createVehicle( math.random(400,611), -1655, 1209, 22 ) end end addEventHandler("onClientColShapeHit",Shop,ShopF) function ExitF() destroyElement(LeftB) destroyElement(RightB) destroyElement(ExitB) destroyElement(BuyB) destroyElement(CarOfTheDay) showPlayerHudComponent("all", true) setCameraTarget(localPlayer) showCursor(false) end function LeftFEnter() if isElement( CarOfTheDay ) then local RX, RY, RZ = getElementRotation( CarOfTheDay ) setElementRotation(CarOfTheDay, RX, RY, RZ + 10) end end function RightFEnter() if isElement( CarOfTheDay ) then local RX, RY, RZ = getElementRotation( CarOfTheDay ) setElementRotation(CarOfTheDay, RX, RY, RZ - 10) end end function BuyF() CW = guiCreateWindow(470,244,543,180,"Confirmation",false) CL = guiCreateLabel(2,47,545,20,"Are you sure you want to buy this car for $3.000?",false,CW) guiLabelSetColor(CL,0,255,0) guiLabelSetHorizontalAlign(CL,"center",false) guiSetFont(CL,"default-bold-small") YesB = guiCreateButton(59,115,159,39,"Yes",false,CW) NoB = guiCreateButton(322,115,159,39,"No",false,CW) addEventHandler("onClientGUIClick",NoB,NoF,false) addEventHandler("onClientGUIClick",YesB,YesF,false) end function NoF() destroyElement(CW) end function YesF() Model = getElementModel(CarOfTheDay) Up = getVehicleUpgrades ( CarOfTheDay ) triggerServerEvent("spawnCar",getRootElement(),localPlayer, Model) showCursor(false) end Link to comment
WolfPire Posted February 22, 2012 Author Share Posted February 22, 2012 Shop = createColSphere( -1658, 1211, 8, 2) function ShopF(theElement) if (theElement ~= localPlayer) then return end -- If the player who hit the colshape isn't the client, cancel the function. setCameraMatrix( -1664, 1210, 22, 0, 0, 0, 0, 0) CarOfTheDay = createVehicle( math.random(400,611), -1655, 1209, 22 ) showCursor(true) if (getVehicleType" class="kw2">getVehicleType" class="kw2">getVehicleType(CarOfTheDay) == "Automobile") then setVehicleColor( CarOfTheDay, math.random(0,255), math.random(0,255), math.random(0,255) ) showPlayerHudComponent("all", false) LeftB = guiCreateButton(342,684,176,57,"< Left",false) guiSetFont(LeftB,"default-bold-small") RightB = guiCreateButton(737,684,176,57,"Right >",false) guiSetFont(RightB,"default-bold-small") ExitB = guiCreateButton(539,714,174,26,"Exit",false) guiSetFont(ExitB,"default-bold-small") BuyB = guiCreateButton(539,689,174,26,"Buy",false) guiSetFont(BuyB,"default-bold-small") addEventHandler( "onClientGUIClick",LeftB,LeftFEnter,false ) addEventHandler( "onClientGUIClick",RightB,RightFEnter,false ) addEventHandler( "onClientGUIClick",BuyB,BuyF,false ) addEventHandler( "onClientGUIClick",ExitB,ExitF,false ) else destroyElement(CarOfTheDay) CarOfTheDay = createVehicle( math.random(400,611), -1655, 1209, 22 ) end end addEventHandler("onClientColShapeHit",Shop,ShopF) function ExitF() destroyElement(LeftB) destroyElement(RightB) destroyElement(ExitB) destroyElement(BuyB) destroyElement(CarOfTheDay) showPlayerHudComponent("all", true) setCameraTarget(localPlayer) showCursor(false) end function LeftFEnter() if isElement( CarOfTheDay ) then local RX, RY, RZ = getElementRotation( CarOfTheDay ) setElementRotation(CarOfTheDay, RX, RY, RZ + 10) end end function RightFEnter() if isElement( CarOfTheDay ) then local RX, RY, RZ = getElementRotation( CarOfTheDay ) setElementRotation(CarOfTheDay, RX, RY, RZ - 10) end end function BuyF() CW = guiCreateWindow(470,244,543,180,"Confirmation",false) CL = guiCreateLabel(2,47,545,20,"Are you sure you want to buy this car for $3.000?",false,CW) guiLabelSetColor(CL,0,255,0) guiLabelSetHorizontalAlign(CL,"center",false) guiSetFont(CL,"default-bold-small") YesB = guiCreateButton(59,115,159,39,"Yes",false,CW) NoB = guiCreateButton(322,115,159,39,"No",false,CW) addEventHandler("onClientGUIClick",NoB,NoF,false) addEventHandler("onClientGUIClick",YesB,YesF,false) end function NoF() destroyElement(CW) end function YesF() Model = getElementModel(CarOfTheDay) Up = getVehicleUpgrades ( CarOfTheDay ) triggerServerEvent("spawnCar",getRootElement(),localPlayer, Model) showCursor(false) end WARNING: Loading script failed: cotd/cotd_c.lua:8: ')' expected near 'kw2' I noticed something really new for me in that line. Link to comment
Kenix Posted February 22, 2012 Share Posted February 22, 2012 Shop = createColSphere( -1658, 1211, 8, 2) function ShopF(theElement) if (theElement ~= localPlayer) then return end -- If the player who hit the colshape isn't the client, cancel the function. setCameraMatrix( -1664, 1210, 22, 0, 0, 0, 0, 0) CarOfTheDay = createVehicle( math.random(400,611), -1655, 1209, 22 ) showCursor(true) if ( getVehicleType( CarOfTheDay ) == "Automobile" ) then setVehicleColor( CarOfTheDay, math.random(0,255), math.random(0,255), math.random(0,255) ) showPlayerHudComponent("all", false) LeftB = guiCreateButton(342,684,176,57,"< Left",false) guiSetFont(LeftB,"default-bold-small") RightB = guiCreateButton(737,684,176,57,"Right >",false) guiSetFont(RightB,"default-bold-small") ExitB = guiCreateButton(539,714,174,26,"Exit",false) guiSetFont(ExitB,"default-bold-small") BuyB = guiCreateButton(539,689,174,26,"Buy",false) guiSetFont(BuyB,"default-bold-small") addEventHandler( "onClientGUIClick",LeftB,LeftFEnter,false ) addEventHandler( "onClientGUIClick",RightB,RightFEnter,false ) addEventHandler( "onClientGUIClick",BuyB,BuyF,false ) addEventHandler( "onClientGUIClick",ExitB,ExitF,false ) else destroyElement(CarOfTheDay) CarOfTheDay = createVehicle( math.random(400,611), -1655, 1209, 22 ) end end addEventHandler("onClientColShapeHit",Shop,ShopF) function ExitF() destroyElement(LeftB) destroyElement(RightB) destroyElement(ExitB) destroyElement(BuyB) destroyElement(CarOfTheDay) showPlayerHudComponent("all", true) setCameraTarget(localPlayer) showCursor(false) end function LeftFEnter() if isElement( CarOfTheDay ) then local RX, RY, RZ = getElementRotation( CarOfTheDay ) setElementRotation(CarOfTheDay, RX, RY, RZ + 10) end end function RightFEnter() if isElement( CarOfTheDay ) then local RX, RY, RZ = getElementRotation( CarOfTheDay ) setElementRotation(CarOfTheDay, RX, RY, RZ - 10) end end function BuyF() CW = guiCreateWindow(470,244,543,180,"Confirmation",false) CL = guiCreateLabel(2,47,545,20,"Are you sure you want to buy this car for $3.000?",false,CW) guiLabelSetColor(CL,0,255,0) guiLabelSetHorizontalAlign(CL,"center",false) guiSetFont(CL,"default-bold-small") YesB = guiCreateButton(59,115,159,39,"Yes",false,CW) NoB = guiCreateButton(322,115,159,39,"No",false,CW) addEventHandler("onClientGUIClick",NoB,NoF,false) addEventHandler("onClientGUIClick",YesB,YesF,false) end function NoF() destroyElement(CW) end function YesF() Model = getElementModel(CarOfTheDay) Up = getVehicleUpgrades ( CarOfTheDay ) triggerServerEvent("spawnCar",getRootElement(),localPlayer, Model) showCursor(false) end Syntax bug in forum. if (getVehicleType" class="kw2">getVehicleType" class="kw2">getVehicleType(CarOfTheDay) == "Automobile") then Link to comment
WolfPire Posted February 22, 2012 Author Share Posted February 22, 2012 Thanks, that actually did the trick! Thanks guys =) You both are win =3 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