Wysłany: 2012-09-29, 07:18
karlik131
Wiek: 43 Na forum: 5015 dni Posty: 11
Piwa : 87
Witam mam problem z dodaniem wymagania score na kupno.
Czyli np.
Za na n?? trzeba 10score
ammo_c
GUIEditor_Window = {}
GUIEditor_Button = {}
GUIEditor_Grid = {}
GUIEditor_Window [ 1 ] = guiCreateWindow ( 405 , 58 , 456 , 685 , "Panel Ammo" , false )
local GridList1 = guiCreateGridList ( 16 , 22 , 228 , 653 , false , GUIEditor_Window [ 1 ])
guiGridListSetSelectionMode ( GridList1 , 2 )
local GridList2 = guiCreateGridList ( 248 , 25 , 199 , 510 , false , GUIEditor_Window [ 1 ])
guiGridListSetSelectionMode ( GridList2 , 2 )
Button2 = guiCreateButton ( 250 , 625 , 197 , 51 , "Wyjdz" , false , GUIEditor_Window [ 1 ])
Button1 = guiCreateButton ( 251 , 545 , 196 , 49 , "Daj bron" , false , GUIEditor_Window [ 1 ])
guiSetVisible ( GUIEditor_Window [ 1 ], false )
showCursor ( false )
local team = getTeamFromName ( "Ammonation" )
weapons ={
"Kastet"
}
function show ()
if getPlayerTeam ( getLocalPlayer ()) == team then
local column = guiGridListAddColumn ( GridList1 , "Player" , 0.99 )
local column1 = guiGridListAddColumn ( GridList2 , "Bron" , 0.99 )
local column2 = guiGridListAddColumn ( GridList3 , "Kasa" , 0.50 )
if ( column ) then
for id , playeritem in ipairs ( getElementsByType ( "player" )) do
local row = guiGridListAddRow ( GridList1 )
guiGridListSetItemText ( GridList1 , row , column , getPlayerName ( playeritem ), false , false )
end
for key , weaponName in pairs ( weapons ) do
local row1 = guiGridListAddRow ( GridList2 )
guiGridListSetItemText ( GridList2 , row1 , 1 , weaponName , false , false )
end
end
guiSetVisible ( GUIEditor_Window [ 1 ], true )
showCursor ( true )
end
end
addCommandHandler ( "o" , show )
function close ()
guiSetVisible ( GUIEditor_Window [ 1 ], false )
showCursor ( false )
setTimer ( guiGridListClear , 50 , 1 , GridList2 )
end
addEventHandler ( "onClientGUIClick" , Button2 , close )
function daj ()
local player = guiGridListGetItemText ( GridList1 , guiGridListGetSelectedItem ( GridList1 ), 1 )
local co = guiGridListGetItemText ( GridList2 , guiGridListGetSelectedItem ( GridList2 ), 1 )
triggerServerEvent ( "daj" , getRootElement (), player , co , getLocalPlayer ())
end
addEventHandler ( "onClientGUIClick" , Button1 , daj )
addCommandHandler ( "ammop" , show )
ammo_s
addEvent ( "daj" , true )
addEventHandler ( "daj" , getRootElement (), function( player , co , potem )
local komu = getPlayerFromName ( player )
if co == "Kastet" then
giveWeapon ( komu , 1 , 200 )
setPlayerMoney ( komu , getPlayerMoney ( komu ) - 500 )
setPlayerMoney ( potem , getPlayerMoney ( potem ) + 500 )
end
end )
skrypt na score
addEventHandler ( 'onResourceStart' , getResourceRootElement (),
function()
call ( getResourceFromName ( "scoreboard" ), "addScoreboardColumn" , "Pkt" )
-- call ( getResourceFromName ( "scoreboard" ), "addScoreboardColumn" , "Kasa" )
for theKey , thePlayer in ipairs ( getElementsByType ( "player" )) do
setElementData ( thePlayer , "Pkt" , 0 )
-- setElementData ( thePlayer , "Kasa" , 0 )
end
end )
addEventHandler ( 'onPlayerJoin' , getRootElement (),
function()
setElementData ( source , "Pkt" , 0 )
-- setElementData ( source , "Kasa" , 0 )
end )
function addScore ( points )
setElementData ( source , "points" , getElementData ( source , "points" ) + points )
-- setElementData ( source , "money" , getElementData ( source , "money" ) + kasa )
end
addEvent ( "addScore" , true )
addEventHandler ( "addScore" , getRootElement (), addScore )
--------- dawanie score
addCommandHandler ( "admin.score" ,
function ( player , cmd , nick , kwota )
if nick and kwota then
local aplayer = getPlayerFromName ( nick )
if aplayer then
kwota = tonumber ( kwota )
setElementData ( aplayer , "Pkt" , kwota )
-- givePlayerMoney ( aplayer , kwota )
end
end
end )
Prosze o pomoc albo zrobi? to za mnie(10piw) albo jak napisa?(3piwa).
Ostatnio zmieniony przez karlik131 2012-10-06, 08:51, w całości zmieniany 2 razy
Wysłany: 2012-09-29, 16:14
Jacob
Głupiomądry
Wiek: 28 Na forum: 5502 dni Posty: 967
Nick w MP: Jacob
Piwa : 786
Do funkcji podpi?tej pod event "daj" dodaj
local score = getElementData ( source , "score" )
potem dodajesz do if'a np.
if co == "Kwiaty" and score > 10 then
Wysłany: 2012-09-29, 20:36
luki123luki123
Place Game
Wiek: 28 Na forum: 5275 dni Posty: 1948
Nick w MP: LuKiO
Piwa : 6101
Wysłany: 2012-09-30, 09:19
karlik131
Wiek: 43 Na forum: 5015 dni Posty: 11
Piwa : 87
if co == "Kastet" and score > 10 then
giveWeapon ( komu , 1 , 200 )
setPlayerMoney ( komu , getPlayerMoney ( komu ) - 500 )
setPlayerMoney ( potem , getPlayerMoney ( potem ) + 500 )
end
function daj ()
local player = guiGridListGetItemText ( GridList1 , guiGridListGetSelectedItem ( GridList1 ), 1 )
local co = guiGridListGetItemText ( GridList2 , guiGridListGetSelectedItem ( GridList2 ), 1 )
triggerServerEvent ( "daj" , getRootElement (), player , co , getLocalPlayer ())
local score = getElementData ( source , "score" )
end
Nie dzia?a teraz nawet broni nie daje.
Ostatnio zmieniony przez karlik131 2012-10-06, 09:20, w całości zmieniany 2 razy
Wysłany: 2012-09-30, 10:16
Riot
3X
Wiek: 29 Na forum: 5729 dni Posty: 1123
Nick w MP: Riot/3X
Piwa : 286
Po pierwsze, jest ?atwiejszy spos?b na dodawanie i zabieranie graczowi kasy ni? Tw?j spos?b:
takePlayerMoney
givePlayerMoney
Wpisz /debugscript 3 i zresetuj skrypt i zobacz czy co? wyskakuje. Co do oddzielnych skrypt?w to nic, i tak b?dzie dzia?a? bo kiedy? testowa?em, tylko obydwa skrypty musz? by? w??czone.
Wysłany: 2012-09-30, 12:12
karlik131
Wiek: 43 Na forum: 5015 dni Posty: 11
Piwa : 87
Przy dawaniu broni w debugscript 3 jest :
Error:[RPG]/panelammo/...../ammo_s.lua: 4 : attempt to compare number with nil
Tagi: panel :: ammo
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: