Wysłany: 2020-02-10, 16:43
Josemitek
Wiek: 26 Na forum: 2404 dni Posty: 17
Nick w MP: Josek
Witam, mam problem. Zrobi?em premium i jak wpisuje kod w pole premium to po wpisaniu randomowych znak?w i tak doda mi punkt do kupna premium. Co ?le robi??
api = "MOJEAPI"
addEvent ( "sprawdzPremium" , true )
addEventHandler ( "sprawdzPremium" , root , function( code , amount )
outputDebugString ( code .. ":" .. amount )
local query = string . format ( "http://admin.serverproject.pl/api/smsapi.php?key=" .. api .. "&amount=%s&code=%s&desc=%s" , tostring ( amount ), code , getElementData ( client , "id:player" ))
fetchRemote ( query , dajP , "" , false , client , amount )
end )
function dajP ( responseData , nerro , playerToReceive , amount )
if nerro == 0 then
if string . find ( responseData , "code" ) then
if string . find ( responseData , '"number":"7136"' ) then
amount = 1
elseif string . find ( responseData , '"number":"7355"' ) then
amount = 3
elseif string . find ( responseData , '"number":"7555"' ) then
amount = 7
elseif string . find ( responseData , '"number":"7936"' ) then
amount = 14
elseif string . find ( responseData , '"number":"92555"' ) then
amount = 30
end
exports [ "notyfikacje" ]: notka ( "Zakupi?e? " .. amount .. "punkt?w premium" , playerToReceive , "sukces" )
outputChatBox ( getPlayerName ( playerToReceive ).. " kupi? " .. amount .. "PP, dzi?kujemy ?e nas wspierasz!" , root , 0 , 255 , 0 )
setElementData ( playerToReceive , "pp" , ( getElementData ( playerToReceive , "pp" ) or 0 )+ amount )
else
exports [ "notyfikacje" ]: notka ( "Podany kod jest nieprawid?owy. (" .. responseData .. ")" , playerToReceive , "blad" )
end
end
end
Wysłany: 2020-02-10, 17:46
Maniekxx
Amator
Wiek: 24 Na forum: 2894 dni Posty: 232
Nick w MP: Maniekxx
Piwa : 225
Spr?buj tak
api = "MOJEAPI"
addEvent ( "sprawdzPremium" , true )
addEventHandler ( "sprawdzPremium" , root , function( code , amount )
outputDebugString ( code .. ":" .. amount )
local query = string . format ( "http://admin.serverproject.pl/api/smsapi.php?key=" .. api .. "&amount=%s&code=%s&desc=%s" , tostring ( amount ), code , getElementData ( client , "id:player" ))
fetchRemote ( query , dajP , "" , false , client , amount )
end )
function dajP ( responseData , nerro , playerToReceive , amount )
if nerro == 0 then
if string . find ( responseData , "code" ) == false then outputChatBox ( "* Podany kod jest nieprawid?owy!" ) -- Musisz jeszcze zdefiniowa ? gracze , nie wiem czy kod jest po stronie Client 'a czy Serwer' a .
if string . find ( responseData , '"number":"7136"' ) then
amount = 1
elseif string . find ( responseData , '"number":"7355"' ) then
amount = 3
elseif string . find ( responseData , '"number":"7555"' ) then
amount = 7
elseif string . find ( responseData , '"number":"7936"' ) then
amount = 14
elseif string . find ( responseData , '"number":"92555"' ) then
amount = 30
end
exports [ "notyfikacje" ]: notka ( "Zakupi?e? " .. amount .. "punkt?w premium" , playerToReceive , "sukces" )
outputChatBox ( getPlayerName ( playerToReceive ).. " kupi? " .. amount .. "PP, dzi?kujemy ?e nas wspierasz!" , root , 0 , 255 , 0 )
setElementData ( playerToReceive , "pp" , ( getElementData ( playerToReceive , "pp" ) or 0 )+ amount )
else
exports [ "notyfikacje" ]: notka ( "Podany kod jest nieprawid?owy. (" .. responseData .. ")" , playerToReceive , "blad" )
end
end
end
Wysłany: 2020-02-10, 18:57
Josemitek
Wiek: 26 Na forum: 2404 dni Posty: 17
Nick w MP: Josek
Teraz jest niby okej, ale jak kupie premium, przepisze kod z smsa to wyskakuje: Podany kod jest nieprawid?owy. ({"status":"ok","amount":"1"}) czyli nieprawid?owa kwota netto sms'a. Je?li wpisze inny kod lub ten sam znow (wykorzystany): Podany kod jest nieprawid?owy. ({"status":"fail","error":"bad_code"}) czyli poprostu b??dny/wykorzystany kod. A i wiadomo?? na chacie jak bledny kod wprowadzam nie wyskakuje. Kod jest po stronie serwera.
Wysłany: 2020-02-10, 20:15
Wilq
Wiek: 24 Na forum: 4429 dni Posty: 3410
Piwa : 739
Jeste? pewny, ?e API zwraca Ci numer SMS'a a nie kwot?? Przygl?dnij si? stronie odno?nie API SMS na ServerProject.
Tymczasem podrzuc? Ci cz??? przyk?adowego gotowego kodu zastosowania API wykonanego przez .WhiteBlue dla ServerProject.
if string . find ( responseData , '"error":"bad_code"' ) then
outputChatBox ( '* Wprowadzony kod jest nieprawid?owy lub zosta? wykorzystany.' , playerToReceive )
return
end
if string . find ( responseData , '"status":"fail"' ) then
outputChatBox ( '* Wyst?pi? nieznany b??d podczas zakupu us?ugi.' , playerToReceive )
return
end
local days = nil
if string . find ( responseData , '"amount":"1"' ) then days = 3 end
if string . find ( responseData , '"amount":"2"' ) then days = 7 end
if string . find ( responseData , '"amount":"3"' ) then days = 14 end
if string . find ( responseData , '"amount":"4"' ) then days = 30 end
Pe?ny zas?b: http://serverproject.eu/files/smsapi-v1-lua.zip
Więcej szczegółów
Wystawiono 1 piw(a):Josemitek
Wysłany: 2020-02-10, 20:31
Josemitek
Wiek: 26 Na forum: 2404 dni Posty: 17
Nick w MP: Josek
Dobra, moja g?upota nie zna granic ;D Dziekuje ci kolejny raz WIlqu!
Tagi: premium
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: