Wysłany: 2014-07-22, 15:56
Mizy1999
I <3 Mta
Wiek: 28 Na forum: 4995 dni Posty: 157
Nick w MP: xxx
Piwa : 154
Witam, znalaz?em temat na necie w kt?rym by? zamieszczony kod do pracy Mechanika, aczkolwiek kod mi nie dzia?a, prosi? bym o pomoc.
C-side:
Kod: local marker = createMarker( 1037.8309326172, -1029.5063476563, 31.1015625, "Cylinder", 1.5, 255, 153, 0, 150)
local localVehicle = getPedOccupiedVehicle(localPlayer)
--- marker createMarker ( float x, float y, float z, [string theType, float size, int r, int g, int b, int a] )
GUIEditor_Button = {}
GUIEditor_Memo = {}
GUIEditor_Label = {}
function guiMyCwindow(w,h,t)
local x,y = guiGetScreenSize()
return guiCreateWindow((x-w)/2,(y-h)/2,w,h,t,false)
end
windowjob = guiMyCwindow(301,250,"mechanic job")
guiSetVisible(windowjob, false)
GUIEditor_Button[1] = guiCreateButton(22,200,108,35,"Take job",false,windowjob)
GUIEditor_Label[1] = guiCreateLabel(193,-103,5,5,"",false,windowjob)
GUIEditor_Button[2] = guiCreateButton(179,200,110,36,"Cancel",false,windowjob)
GUIEditor_Memo[1] = guiCreateMemo(19,33,273,100,"To take mechanic job, press Take job.\n\nIf you don't want to, press Cancel.",false,windowjob)
guiEditSetReadOnly(GUIEditor_Memo[1],true)
function mecjob(hitElement)
if getElementType(hitElement) == "player" then
if not guiGetVisible(windowjob) then
guiSetVisible(windowjob, true)
showCursor(true)
end
end
end
addEventHandler("onClientMarkerHit", marker, mecjob)
function mecjobleave(leaveElement)
if getElementType(leaveElement) == "player" then
if guiGetVisible(windowjob) then
guiSetVisible(windowjob, false)
showCursor(false)
end
end
end
addEventHandler("onClientMarkerLeave", marker, mecjobleave)
function joinTeam()
triggerServerEvent("setMec",localPlayer)
guiSetVisible(windowjob, false)
showCursor(false)
end
addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false)
function removemecWindow()
guiSetVisible(windowjob, false)
showCursor(false)
end
addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removemecWindow, false)
addEventHandler("onClientPlayerDamage", localVehicle,
function(attacker, weapon, bodypart, loss)
team = getPlayerTeam(attacker)
if (attacker and getElementType(attacker) == "player" and weapon == 42 and team and getTeamName(team) == "Mechanic") then
cancelEvent() -- Cancels the damage cause by the spray
if (not isTimer(pause)) then
if (health < 99) then
triggerServerEvent("mechanic:repair", localVehicle, attacker) -- Calls the Server Event
pause = setTimer(function() end, 1000, 1) -- Makes a timer for the function so it won't fully heal in the first time
end
end
end
end
S-side:
Kod: createBlip ( 1036.1654052734, -1027.8570556641, 32.1015625, 27 )
function createMechanicTeam ()
mecTeam = createTeam ("Mechanic", 255, 153, 0)
end
addEventHandler ("onResourceStart", resourceRoot, createMechanicTeam)
function joinMec()
setPlayerTeam(source,mecTeam)
setElementModel(source, 50)
giveWeapon ( source, 42, 999 )
setElementData( source, "Occupation", "Mechanic", true )
outputChatBox("You are now Mechanic.",source,0,255,0)
end
addEvent("setMec", true)
addEventHandler("setMec", root, joinMec )
addEvent("mechanic:repair", true)
addEventHandler("mechanic:repair", root,
function (mechanic)
if (getElementHealth(localVehicle) < 100) then
local Heal = getElementHealth(localVehicle) + 10 -- New health
setElementHealth(localVehicle, Heal)
if (Heal > 100) then
setElementHealth(localVehicle, 1000)
end
givePlayerMoney(mechanic, 1000) -- Gives 100$ to the medic each time the function is executed
end
end
Meta:
Kod: <meta>
<script src="mechanik-c.lua" type="client" />
<script src="mechanik-s.lua" type="server" />
</meta>
Wysłany: 2014-07-22, 16:35
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4394 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
Wysłany: 2014-07-22, 23:49
Maciąg
Wiek: 26 Na forum: 4376 dni Posty: 211
Nick w MP: Dawirzo
Piwa : 149
Sp?jrz w S-side, na ko?cu po end nie ma )
Podpis
Status prac nad Time to play RPG 25%
Wysłany: 2014-07-22, 23:50
krydianero
Samotny Wilk
Wiek: 33 Na forum: 4782 dni Posty: 395
Nick w MP: Yoshida
Piwa : 1798
S-Side
createBlip ( 1036.1654052734 , - 1027.8570556641 , 32.1015625 , 27 )
function createMechanicTeam ()
mecTeam = createTeam ( "Mechanic" , 255 , 153 , 0 )
end
addEventHandler ( "onResourceStart" , resourceRoot , createMechanicTeam )
function joinMec ()
setPlayerTeam ( source , mecTeam )
setElementModel ( source , 50 )
giveWeapon ( source , 42 , 999 )
setElementData ( source , "Occupation" , "Mechanic" , true )
outputChatBox ( "You are now Mechanic." , source , 0 , 255 , 0 )
end
addEvent ( "setMec" , true )
addEventHandler ( "setMec" , root , joinMec )
addEvent ( "mechanic:repair" , true )
addEventHandler ( "mechanic:repair" , root ,
function ( mechanic )
if ( getElementHealth ( localVehicle ) < 100 ) then
local Heal = getElementHealth ( localVehicle ) + 10 -- New health
setElementHealth ( localVehicle , Heal )
if ( Heal > 100 ) then
setElementHealth ( localVehicle , 1000 )
end
givePlayerMoney ( mechanic , 1000 ) -- Gives 100 $ to the medic each time the function is executed
end
end
)
Podpis
Multi Drive Unlimited:Nowy projekt już wkrótce
Wysłany: 2014-07-22, 23:51
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4394 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
setElementData ( source , "Occupation" , "Mechanic" , true )
Co to jest ? Kolego polecam zacz?? od s?abszych funkcji ?eby czego? si? nauczy? dopiero potem zabiera? si? za kodowanie.
Wysłany: 2014-07-22, 23:54
krydianero
Samotny Wilk
Wiek: 33 Na forum: 4782 dni Posty: 395
Nick w MP: Yoshida
Piwa : 1798
PanMaszyna , ja tego nie napisa?em, doda?em tylko nawias ")" na ko?cu, kt?rego brakowa?o.
Podpis
Multi Drive Unlimited:Nowy projekt już wkrótce
Ostatnio zmieniony przez krydianero 2014-07-22, 23:54, w całości zmieniany 1 raz
Wysłany: 2014-07-22, 23:54
Maciąg
Wiek: 26 Na forum: 4376 dni Posty: 211
Nick w MP: Dawirzo
Piwa : 149
PanMaszyna , ale on pisa?, ?e ten skrypt znalaz? na necie i nie wie dlaczego mu nie dzia?a.
[ Dodano : 2014-07-22, 23:55 ]
krydianero , Ale dalej nie dzia?a?
[ Dodano : 2014-07-22, 23:56 ]
W C-side te? brakuje na ko?cu nawiasu. Popraw i sprawd?
Podpis
Status prac nad Time to play RPG 25%
Wysłany: 2014-07-22, 23:58
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4394 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
To tym bardziej zach?cam do nauki LUA.
Wysłany: 2014-07-23, 00:10
Maciąg
Wiek: 26 Na forum: 4376 dni Posty: 211
Nick w MP: Dawirzo
Piwa : 149
Tak maszyna, ale gdzie? Ksi??ek o tym nie ma, a filmiki na YT najcz??ciej angielskie. Mi dzi? wpad? taki pomys?, ?eby? ty nagrywa?
Podpis
Status prac nad Time to play RPG 25%
Wysłany: 2014-07-23, 00:44
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4394 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
Du?o jest poradnik?w na gtao i innych forach i bodaj?e Piorun nagrywa wi?c nie potrzeba dw?ch.
Wysłany: 2014-07-23, 18:57
Mizy1999
I <3 Mta
Wiek: 28 Na forum: 4995 dni Posty: 157
Nick w MP: xxx
Piwa : 154
Oczywi?cie znam podstawowe funkcje, lecz masz racj?, znalaz?em ten poradnik pioruna, przysi?d? troch?. Staram si? zrobi? jaki? serwer tak by m?c pogra? z przyjaci??mi. Nie robi? kolejnego pse?dola Dzi?ki za podsuni?cie go?cia kt?ry nagrywa, je?eli czego? mnie nauczy to b?dzie super Pozdrawiam.
Tagi: praca :: mechanika
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: