It is currently Tue 19. Mar 2024 4:41:04

All times are UTC + 1 hour [ DST ]




Post new topic  Post a reply   Page 1 of 1  [ 2 posts ] 
Author Message

[SAM]Miki_Cz
 Post subject: Oprava auta za penize
PostPosted: Sat 14. Apr 2012 23:28:22 
offline
Hlavní Administrátor
Hlavní Administrátor
User avatar

Joined: Thu 13. Oct 2011 18:32:25
Posts: 1625
Location: Dublin, Irsko

Admin Level: 5
Points: 1 581 548
Cash: $1 738 468
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 :D

___________________
Ten nepodstatnej hlavni admin :D
Image


Top
   
 

PostPosted: Fri 30. Nov 2012 20:46:48 
offline
Nováček
Nováček

Joined: Wed 08. Aug 2012 13:29:37
Posts: 19
Č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)


Top
   
 
Display posts from previous:  Sort by  
Post new topic  Post a reply   Page 1 of 1  [ 2 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
TOPlist
Powered by phpBB® Forum Software © phpBB Group

©MSHost.cz