Wysłany: 2016-11-27, 15:25
Pumelowsky
Amator 3D
Wiek: 23 Na forum: 4181 dni Posty: 199
Nick w MP: Pumelowsky
Piwa : 1666
Witam ot?? napisa?em grosze na hudzie za pomoca string.gsub i chcialbym zeby przy przelewie,wystawianiu ceny auta. Jak wpisuje /przelej id 433.31 to przelewa sie 433 i zostaje 0.31. Jak zrobi? by grosze te? sie przelewaly?
KOD:
function zaplac ( plr , cmd , target , ile )
if not getElementData ( plr , "user:logged" ) then return end
if not target or not ile then
outputChatBox ( "#ffc800U?yj: #eeeeee/" .. cmd .. " [ID/Nazwa gracza] [Kwota]" , plr , 255 , 255 , 255 , true )
return
end
local target = findPlayer ( plr , target )
if not target then return end
local ile = tonumber ( ile )
string . format ( "%.2f" , ile / 100 )
string . gsub ( ile , "^(-?%d+)(%d%d)" , '%1,%2' )
if not ile then
exports . rpg_noti : createNotification ( plr , "error" , "Wpisana wartos? musi by? liczb?" , 1 )
return
end
local ile = math . floor ( ile )
if ile < 0.01 then
exports . rpg_noti : createNotification ( plr , "error" , "Wpisana wartos? musi by? wi?ksza od 0" , 1 )
return
end
local money1 = getPlayerMoney ( plr )
string . format ( "%.2f" , money1 / 100 )
string . gsub ( money1 , "^(-?%d+)(%d%d)" , '%1,%2' )
if money1 < ile then
exports . rpg_noti : createNotification ( plr , "error" , "Nie posiadasz przy sobie takiej sumy" , 1 )
return
end
takePlayerMoney ( plr , ile * 100 )
givePlayerMoney ( target , ile * 100 )
string . gsub ( ile , "^(-?%d+)(%d%d)" , '%1,%2' )
outputChatBox ( "#c1c1c1Przekazujesz graczowi #e5e5e5" .. getElementData ( target , "user:imie" ).. " " .. getElementData ( target , "user:nazwisko" ).. "#c1c1c1 kwot? #e5e5e5" .. ile .. " PLN" , plr , 255 , 255 , 255 , true )
outputChatBox ( "#c1c1c1Otrzymujesz od gracza #e5e5e5" .. getElementData ( plr , "user:imie" ).. " " .. getElementData ( plr , "user:nazwisko" ).. "#c1c1c1 kwot? #e5e5e5" .. ile .. " PLN" , target , 255 , 255 , 255 , true )
local player_id = getElementData ( plr , "user:uid" )
local player_name = tostring ( getElementData ( target , "user:imie" ).. " " .. getElementData ( target , "user:nazwisko" ))
local target_id = getElementData ( target , "user:uid" )
local target_name = tostring ( getElementData ( target , "user:imie" ).. " " .. getElementData ( target , "user:nazwisko" ))
exports . rpg_admin : addToEcho ( "#71E83A[PRZELEW] #ffffff" .. player_name .. "/" .. player_id .. " > " .. target_name .. "/" .. target_id .. ": " .. ile .. " PLN" )
end
addCommandHandler ( "przelej" , zaplac )
addCommandHandler ( "zaplac" , zaplac )
Prosz? o szybk? pomoc!!!
Podpis
Kontakt:
- Skype: live:pumapl_2
- GG: 56865468
- Discord: Pumelowsky#1126
- PW forum
[/center]
Wysłany: 2016-11-27, 17:52
luki123luki123
Place Game
Wiek: 28 Na forum: 5275 dni Posty: 1948
Nick w MP: LuKiO
Piwa : 6101
PumaPL123 , local ilosc = "192.52"
local pieniadze = string . gsub ( ilosc , "." , "" )
result : 19252
sprawdz tak powino podzia?a? ;D
Wysłany: 2016-11-27, 18:28
Pumelowsky
Amator 3D
Wiek: 23 Na forum: 4181 dni Posty: 199
Nick w MP: Pumelowsky
Piwa : 1666
luki123luki123 , Jak to w kodzie zastosowac?
Podpis
Kontakt:
- Skype: live:pumapl_2
- GG: 56865468
- Discord: Pumelowsky#1126
- PW forum
[/center]
Wysłany: 2016-11-27, 19:49
Jurandovsky
Kurdebele
Wiek: 17 Na forum: 4838 dni Posty: 915
Piwa : 2697
Do takich rzeczy mo?esz te? u?y? np. split, kt?ry Ci zwr?ci tabel? [1] to b?dzie cena przed kropk?, [2] to te Twoje upragnione grosze.
Bad? te? math.modf, kt?re rozbija liczb? do 2 zmiennych:
local liczba = 192.52
local m1 , m2 = math . modf ( liczba )
print( "ca?osci: " .. m1 .. " grosze: " .. m2 )
Podpis
Jedyny kontakt ze mną to PW forum
Kod:
local noobs = getElementsByTitle("player", "Programista LUA")
for k, v in ipairs(noobs) do
outputChatBox("Bez mózgu jest użytkownik o nicku: "..getPlayerName(v), root)
destroyElement(v)
end
Wysłany: 2016-11-27, 20:01
Pumelowsky
Amator 3D
Wiek: 23 Na forum: 4181 dni Posty: 199
Nick w MP: Pumelowsky
Piwa : 1666
Niewa?ne juz sobie poradzilem, do zamknieca.
Podpis
Kontakt:
- Skype: live:pumapl_2
- GG: 56865468
- Discord: Pumelowsky#1126
- PW forum
[/center]
Tagi: grosze :: przy :: chatcie
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: