MSHost.cz https://forum.mshost.cz:443/ |
|
Oprava auta za penize https://forum.mshost.cz:443/viewtopic.php?f=18&t=949 |
Page 1 of 1 |
Author: | MIKI785 [ Sat 14. Apr 2012 23:28:22 ] |
Post subject: | Oprava auta za penize |
Zdravim, zde vam ukazu jak na opravu auta za neaky ten peniz, penize zjistite a nastavite funkcemi getPlayerMoney a setPlayerMoney. Zde neni co vysvetlovat, komentare mate primo v kodu. Code: function oprava (player, command) if (getPlayerMoney(player) < 1500) then --Jestli ma hrac vice jak 1500.. local auto = getPedOccupiedVehicle(player) --Nadefinuje auto ("element") k oprave fixVehicle(auto) --samotna oprava setPlayerMoney(player, getPlayerMoney(player) - 1500 ) --Odecte mu $1500 outputChatBox("Nechal jsi si opravit auto za $1500! Tvuj zustatek na uctu cini $" .. getPlayerMoney(player), player, 250, 0, 0) --Vypise cervenou zpravu se zustatkem na uctu. else --Pokud ma min jak 1500.. outputChatBox("Nemas dost prasuli, potrebujes $1500!", player, 250, 0, 0 ) end --Konec podminky end --konec funkce addCommandHandler("fixniAuto", oprava) --Prida prikaz /fixniAuto Vic komentaru neni treba. Netestoval sem to ale chyby by tam byt nemeli |
Author: | JoZeF [ Fri 30. Nov 2012 20:46:48 ] |
Post subject: | Re: Oprava auta za penize |
Čau, chcel by som sa ťa opýtat o ten navod čo si robil na tvojom fore (posielal som ti to na skype ale bol si asi zaneprazdneni tak ti to pisem tu) mam panel a chcel by som tam pridat ten fix , ale cez get player money to nejde lebo ten script uklada do vlastnej zlozky database.xml , no nasiel som tam v tom scripte pri kupovani mapy playerCash , snazil som sa to nahradit namiesto get player cash ale vypisalo error ze funkcia nevyhodila ziadnu hodnotu, pravdepodobne neexistuje alebo ne tak sa zapisuje alebo neni definovana ale syntax sedi vyzeralo to asi takto po uprave Code: function oprava (player, command) if (getPlayerMoney(player) < 1500) then --Jestli ma hrac vice jak 1500.. local auto = getPedOccupiedVehicle(player) --Nadefinuje auto ("element") k oprave fixVehicle(auto) --samotna oprava setPlayerMoney(player, playerCash(player) - 1500 ) --Odecte mu $1500 outputChatBox("Nechal jsi si opravit auto za $1500! Tvuj zustatek na uctu cini $" .. playerCash(player), player, 250, 0, 0) --Vypise cervenou zpravu se zustatkem na uctu. else --Pokud ma min jak 1500.. outputChatBox("Nemas dost prasuli, potrebujes $1500!", player, 250, 0, 0 ) end --Konec podminky end --konec funkce addCommandHandler("fixniAuto", oprava) --Prida prikaz /fixniAuto player cash tam nesedi , no neviem , dedukoval som to z casti "prevod penazi" give money ktora vyzerala asi takto , (davam pre pripad ak by nieco pomohlo pre napady) Code: function giveMoney(thePlayer,CMD,targetPlayer,amount)
if not (targetPlayer == "") then if tonumber(amount) then local playerCash = tonumber(loadPlayerData(thePlayer,"cash")) if tonumber(amount) > 0 then if tonumber(amount) <= playerCash then if (findPlayerByName(targetPlayer)) then local target = findPlayerByName(targetPlayer) if target ~= thePlayer then local amount = math.ceil(amount) local playerCash = loadPlayerData(thePlayer,"cash") local targetCash = loadPlayerData(target,"cash") savePlayerData(thePlayer,"cash",playerCash-tonumber(amount)) CheckAchievement(thePlayer,15) savePlayerData(target,"cash",targetCash+tonumber(amount)) CheckAchievement(target,15) local playerCash = loadPlayerData(thePlayer,"cash") local targetCash = loadPlayerData(target,"cash") scoreboardRefresh(thePlayer) scoreboardRefresh(target) outputChatBox("#00AAFF# #FFFFFFYou have sent #00AAFF$"..amount.."#FFFFFF to "..getPlayerName(target).."#FFFFFF!",thePlayer,255,255,255,true) outputChatBox("#00AAFF# #FFFFFF"..getPlayerName(thePlayer).." #FFFFFFhas sent you #00AAFF$"..amount.."#FFFFFF!",target,255,255,255,true) else outputChatBox("#00AAFF# #FFFFFFERROR! You cannot send money to yourself!",thePlayer,255,255,255,true) return false end else outputChatBox("#00AAFF# #FFFFFFERROR! The player you specified does not exist!",thePlayer,255,255,255,true) return false end else outputChatBox("#00AAFF# #FFFFFFERROR! You don't have enough money!",thePlayer,255,255,255,true) return false end else outputChatBox("#00AAFF# #FFFFFFERROR! Invalid amount! [#00AAFF"..amount.."#FFFFFF]",thePlayer,255,255,255,true) return false end else outputChatBox("#00AAFF# #FFFFFFERROR! Please specify the amount to send!",thePlayer,255,255,255,true) return false end else outputChatBox("#00AAFF# #FFFFFFERROR! Please select a player!",thePlayer,255,255,255,true) return false end end addCommandHandler("givecash", giveMoney) |
Page 1 of 1 | All times are UTC + 1 hour [ DST ] |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |