Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SCRIPT_START
{
LVAR_INT i scplayer hLib bDownloading bForceUpdate pFormText iChar iTotalChars iFormValue iCurrentDollar iLanguage
LVAR_INT pCallAPI pIsDownloadFinished pGetPrice pGetPercent1H pGetPercent24H pGetPercent7D
LVAR_FLOAT f fPrice fPerc1H fPerc24H fPerc7D fLoadingRotation x y fCurrentBTC
CONST_INT KEYBUFFER 0x00969110
CONST_INT LANG_PT 1
CONST_INT LANG_EN 2
GET_PLAYER_CHAR 0 scplayer
IF NOT READ_INT_FROM_INI_FILE "Bitcoin Invest.ini" "Settings" "Language" (iLanguage)
iLanguage = LANG_EN
ENDIF
IF LOAD_DYNAMIC_LIBRARY "BitcoinPrice.asi" (hLib)
IF NOT GET_DYNAMIC_LIBRARY_PROCEDURE "CallAPI" hLib (pCallAPI)
OR NOT GET_DYNAMIC_LIBRARY_PROCEDURE "IsDownloadFinished" hLib (pIsDownloadFinished)
OR NOT GET_DYNAMIC_LIBRARY_PROCEDURE "GetPrice" hLib (pGetPrice)
OR NOT GET_DYNAMIC_LIBRARY_PROCEDURE "GetPercent1H" hLib (pGetPercent1H)
OR NOT GET_DYNAMIC_LIBRARY_PROCEDURE "GetPercent24H" hLib (pGetPercent24H)
OR NOT GET_DYNAMIC_LIBRARY_PROCEDURE "GetPercent7D" hLib (pGetPercent7D)
IF iLanguage = LANG_PT
PRINT_STRING_NOW "~r~Erro: Falha ao ler 'BitcoinPrice.asi'." 5000
ELSE
PRINT_STRING_NOW "~r~Error: Fail to read 'BitcoinPrice.asi'." 5000
ENDIF
FREE_DYNAMIC_LIBRARY (hLib)
TERMINATE_THIS_CUSTOM_SCRIPT
ENDIF
FREE_DYNAMIC_LIBRARY (hLib)
ELSE
IF iLanguage = LANG_PT
PRINT_STRING_NOW "~r~Erro: Falha ao carregar 'BitcoinPrice.asi'." 5000
ELSE
PRINT_STRING_NOW "~r~Error: Fail to load 'BitcoinPrice.asi'." 5000
ENDIF
TERMINATE_THIS_CUSTOM_SCRIPT
ENDIF
WHILE TRUE
WAIT 0
IF TEST_CHEAT BITCOIN
CALL_FUNCTION_RETURN pCallAPI 0 0 (i)
IF i = 0
GOSUB LockPlayer
LOAD_TEXTURE_DICTIONARY BCINVST
LOAD_SPRITE 1 LOADING
LOAD_SPRITE 2 ARROW
i = 0
timera = 0
timerb = 0
fLoadingRotation = 0.0
WHILE TRUE
WAIT 0
USE_TEXT_COMMANDS 1
DRAW_RECT (480.0 310.0) (120.0 120.0) (0 0 0 150)
CLEO_CALL GetXYSizeInScreen4x3ScaleBy640x480 0 (12.0 12.0) (x y)
DRAW_SPRITE_WITH_ROTATION 1 480.0 310.0 x y fLoadingRotation 255 255 255 255
fLoadingRotation +=@ 10.0
USE_TEXT_COMMANDS 0
PRINT_STRING "Downloading..." 1
CALL_FUNCTION_RETURN pIsDownloadFinished 0 0 (i)
IF NOT i = FALSE
GOSUB RunInterface
BREAK
ENDIF
IF timera > 7000
IF iLanguage = LANG_PT
PRINT_STRING_NOW "~r~Falha ao baixar os dados. Verifique sua conexšo." 4000
ELSE
PRINT_STRING_NOW "~r~Fail to download data. Check your internet connection." 4000
ENDIF
BREAK
ENDIF
ENDWHILE
GOSUB UnlockPlayer
USE_TEXT_COMMANDS 0
WAIT 2000
REMOVE_TEXTURE_DICTIONARY
ELSE
i /= 1000
IF iLanguage = LANG_PT
PRINT_FORMATTED_NOW "Estamos usando API gr˜tis limitada, entšo este mod tem limite de uso. Por favor espere %d segs." 5000 i
ELSE
PRINT_FORMATTED_NOW "We are using free limited API, so this mod has use limit. Please wait %d seconds." 5000 i
ENDIF
ENDIF
ENDIF
ENDWHILE
///////////////////////////////////////////////////////////////////////////////////////////////
LockPlayer:
SET_PLAYER_CONTROL 0 FALSE
IF IS_CHAR_DUCKING scplayer
TASK_TOGGLE_DUCK scplayer FALSE
ENDIF
RETURN
UnlockPlayer:
SET_PLAYER_CONTROL 0 TRUE
RETURN
StoreData:
CALL_FUNCTION_RETURN pGetPrice 0 0 (fPrice)
POP_FLOAT fPrice
IF fPrice <= 1.0
IF iLanguage = LANG_PT
PRINT_STRING_NOW "~r~Falha ao baixar. Estamos usando API gr˜tis limitada, então muitas pessoas devem estar usando este mod hoje. Relate." 7000
ELSE
PRINT_STRING_NOW "~r~Fail to download. We are using free limited API, so maybe there is too much people using this mod today. Report it." 7000
ENDIF
WAIT 4000
RETURN_FALSE
RETURN
ENDIF
GET_LABEL_POINTER BCPRIC (i)
STRING_FORMAT i "$%.2f" (fPrice)
ADD_TEXT_LABEL _BCPRIC $i
CALL_FUNCTION_RETURN pGetPercent1H 0 0 (fPerc1H)
POP_FLOAT fPerc1H
GET_LABEL_POINTER BCPR1H (i)
STRING_FORMAT i "%.2f%%" (fPerc1H)
ADD_TEXT_LABEL _BCPR1H $i
CALL_FUNCTION_RETURN pGetPercent24H 0 0 (fPerc24H)
POP_FLOAT fPerc24H
GET_LABEL_POINTER BCPR2H (i)
STRING_FORMAT i "%.2f%%" (fPerc24H)
ADD_TEXT_LABEL _BCPR2H $i
CALL_FUNCTION_RETURN pGetPercent7D 0 0 (fPerc7D)
POP_FLOAT fPerc7D
GET_LABEL_POINTER BCPR7D (i)
STRING_FORMAT i "%.2f%%" (fPerc7D)
ADD_TEXT_LABEL _BCPR7D $i
STORE_SCORE 0 iCurrentDollar
GET_LABEL_POINTER BCDOLL (i)
STRING_FORMAT i "$%i" (iCurrentDollar)
ADD_TEXT_LABEL _BCDOLL $i
CLEO_CALL ReadGlobalFloatVar 0 (636)(fCurrentBTC)
CLEO_CALL ReadGlobalFloatVar 0 (637)(f)
IF NOT f = fCurrentBTC // Validate value
fCurrentBTC = 0.0
CLEO_CALL WriteGlobalFloatVar 0 (636 fCurrentBTC)
CLEO_CALL WriteGlobalFloatVar 0 (637 fCurrentBTC)
ENDIF
GET_LABEL_POINTER BCCBTC (i)
STRING_FORMAT i "BTC %.6f" (fCurrentBTC)
ADD_TEXT_LABEL _BCCBTC $i
GOSUB Keyboard_UpdateGXT
RETURN_TRUE
RETURN
RunInterface:
IF GOSUB StoreData
ELSE
RETURN
ENDIF
GOSUB InitKeyboard
timerb = 0
bForceUpdate = FALSE
bDownloading = FALSE
WHILE TRUE
GOSUB ProcessAndDrawInterface
IF IS_KEY_PRESSED VK_RETURN
BREAK
ENDIF
IF bDownloading = TRUE
CALL_FUNCTION_RETURN pIsDownloadFinished 0 0 (i)
IF i = FALSE
IF timera > 5000
IF iLanguage = LANG_PT
PRINT_STRING_NOW "~r~Error: Falha ao atualizar os dados." 5000
ELSE
PRINT_STRING_NOW "~r~Error: Fail to refresh data." 5000
ENDIF
RETURN
ENDIF
ELSE
IF GOSUB StoreData
ELSE
BREAK
ENDIF
bDownloading = FALSE
timerb = 0
ENDIF
ELSE
IF timerb > 61000
OR bForceUpdate = TRUE
CALL_FUNCTION_RETURN pCallAPI 0 0 (i) // Update price
IF NOT i = 0
PRINT_FORMATTED_NOW "~r~Error: Call limit: %i" 2000 i
RETURN
ENDIF
IF iLanguage = LANG_PT
PRINT_STRING "~y~Atualizando..." 1500
ELSE
PRINT_STRING "~y~Refreshing..." 1500
ENDIF
fLoadingRotation = 0.0
bDownloading = TRUE
timera = 0
timerb = 0
ENDIF
ENDIF
GOSUB Keyboard
IF IS_KEY_PRESSED VK_LSHIFT
OR IS_KEY_PRESSED VK_RSHIFT
IF iFormValue > 0
STORE_SCORE 0 iCurrentDollar
IF iCurrentDollar >= iFormValue
IF fPrice <= 1.0
PRINT_STRING "~r~Error 1A." 1500
BREAK
ENDIF
f =# iFormValue
f /= fPrice
fCurrentBTC += f
CLEO_CALL WriteGlobalFloatVar 0 (636 fCurrentBTC)
CLEO_CALL WriteGlobalFloatVar 0 (637 fCurrentBTC)
i = iFormValue * -1
ADD_SCORE 0 i
iFormValue = 0
iTotalChars = 0
WRITE_MEMORY pFormText 4 0 FALSE
GOSUB StoreData
ELSE
IF iLanguage = LANG_PT
PRINT_STRING "~r~VocŸ nšo tem d¦lares o suficiente." 1500
ELSE
PRINT_STRING "~r~You don't have enough dollars." 1500
ENDIF
ENDIF
ELSE
IF iLanguage = LANG_PT
PRINT_STRING "~r~Digite um valor." 500
ELSE
PRINT_STRING "~r~Enter a value." 500
ENDIF
ENDIF
WHILE IS_KEY_PRESSED VK_LSHIFT
OR IS_KEY_PRESSED VK_RSHIFT
GOSUB ProcessAndDrawInterface
ENDWHILE
ENDIF
IF IS_KEY_PRESSED VK_LCONTROL
OR IS_KEY_PRESSED VK_RCONTROL
IF iFormValue > 0
IF fPrice <= 1.0
PRINT_STRING "~r~Error 1A." 1500
BREAK
ENDIF
f =# iFormValue
f /= fPrice
IF f <= fCurrentBTC
fCurrentBTC -= f
CLEO_CALL WriteGlobalFloatVar 0 (636 fCurrentBTC)
CLEO_CALL WriteGlobalFloatVar 0 (637 fCurrentBTC)
ADD_SCORE 0 iFormValue
iFormValue = 0
iTotalChars = 0
WRITE_MEMORY pFormText 4 0 FALSE
GOSUB StoreData
ELSE
IF iLanguage = LANG_PT
PRINT_STRING "~r~VocŸ nšo tem BTCs o suficiente." 1500
ELSE
PRINT_STRING "~r~You don't have enough BTCs." 1500
ENDIF
ENDIF
ELSE
IF iLanguage = LANG_PT
PRINT_STRING "~r~Digite um valor." 500
ELSE
PRINT_STRING "~r~Enter a value." 500
ENDIF
ENDIF
WHILE IS_KEY_PRESSED VK_LCONTROL
OR IS_KEY_PRESSED VK_RCONTROL
GOSUB ProcessAndDrawInterface
ENDWHILE
ENDIF
ENDWHILE
RETURN
ProcessAndDrawInterface:
WAIT 0
USE_TEXT_COMMANDS 1
// Background
DRAW_RECT (480.0 310.0) (120.0 120.0) (0 0 0 150)
CLEO_CALL GetXYSizeInScreen4x3ScaleBy640x480 0 (9.0 9.0) (x y)
// Price
GOSUB FormatText_Desc
DISPLAY_TEXT 430.0 260.0 _BCIPRC
GOSUB FormatText_Value
DISPLAY_TEXT 460.0 260.0 _BCPRIC
// Percent 1H
GOSUB FormatText_Desc
DISPLAY_TEXT 430.0 270.0 _BCIP1H
GOSUB FormatText_Value
IF fPerc1H < 0.000000
DRAW_SPRITE_WITH_ROTATION 2 455.0 274.0 x y 180.0 100 255 50 255
SET_TEXT_COLOUR 100 255 50 255
ELSE
DRAW_SPRITE_WITH_ROTATION 2 455.0 274.0 x y 0.0 255 50 50 255
SET_TEXT_COLOUR 255 50 50 255
ENDIF
DISPLAY_TEXT 460.0 270.0 _BCPR1H
// Percent 24H
GOSUB FormatText_Desc
DISPLAY_TEXT 430.0 280.0 _BCIP2H
GOSUB FormatText_Value
IF fPerc24H > 0.000000
DRAW_SPRITE_WITH_ROTATION 2 455.0 284.0 x y 180.0 100 255 50 255
SET_TEXT_COLOUR 100 255 50 255
ELSE
DRAW_SPRITE_WITH_ROTATION 2 455.0 284.0 x y 0.0 255 50 50 255
SET_TEXT_COLOUR 255 50 50 255
ENDIF
DISPLAY_TEXT 460.0 280.0 _BCPR2H
// Percent 7D
GOSUB FormatText_Desc
DISPLAY_TEXT 430.0 290.0 _BCIP7D
GOSUB FormatText_Value
IF fPerc7D > 0.000000
DRAW_SPRITE_WITH_ROTATION 2 455.0 294.0 x y 180.0 100 255 50 255
SET_TEXT_COLOUR 100 255 50 255
ELSE
DRAW_SPRITE_WITH_ROTATION 2 455.0 294.0 x y 0.0 255 50 50 255
SET_TEXT_COLOUR 255 50 50 255
ENDIF
DISPLAY_TEXT 460.0 290.0 _BCPR7D
DRAW_RECT (475.0 315.0) (90.0 15.0) (0 0 0 100)
GOSUB FormatText_BuySellValue
DISPLAY_TEXT 435.0 310.0 _BCIVAL
GOSUB FormatText_BTCBuySellValue
DISPLAY_TEXT 435.0 324.0 _BCIBTC
IF bDownloading = TRUE
DRAW_SPRITE_WITH_ROTATION 1 525.0 264.0 x y fLoadingRotation 255 255 255 255
DRAW_SPRITE_WITH_ROTATION 1 525.0 274.0 x y fLoadingRotation 255 255 255 255
DRAW_SPRITE_WITH_ROTATION 1 525.0 284.0 x y fLoadingRotation 255 255 255 255
DRAW_SPRITE_WITH_ROTATION 1 525.0 294.0 x y fLoadingRotation 255 255 255 255
fLoadingRotation +=@ 10.0
ENDIF
GOSUB FormatText_BuySellText
DISPLAY_TEXT 440.0 343.0 _BCIBUY
GOSUB FormatText_BuySellCmd
DISPLAY_TEXT 442.5 352.0 _BCIBCM
DRAW_RECT (450.0 350.0) (36.0 20.0) (0 255 0 255)
GOSUB FormatText_BuySellText
DISPLAY_TEXT 500.0 343.0 _BCISEL
GOSUB FormatText_BuySellCmd
DISPLAY_TEXT 506.0 352.0 _BCISCM
DRAW_RECT (510.0 350.0) (36.0 20.0) (255 50 50 255)
DRAW_RECT (480.0 385.0) (120.0 40.0) (0 0 0 255)
GOSUB FormatText_Desc
DISPLAY_TEXT 430.0 370.0 _BCBALC
GOSUB FormatText_BalanceValue
DISPLAY_TEXT 430.0 380.0 _BCDOLL
GOSUB FormatText_BalanceValue
DISPLAY_TEXT 430.0 390.0 _BCCBTC
REMOVE_TEXT_LABEL _BCCRED
ADD_TEXT_LABEL _BCCRED "MixMods.com.br"
GOSUB FormatText_Credits
DISPLAY_TEXT 500.0 395.0 _BCCRED
// ---
USE_TEXT_COMMANDS 0
RETURN
/////////////////////////////////////////////////
InitKeyboard:
iTotalChars = 0
iFormValue = 0
GET_LABEL_POINTER FormText pFormText
WRITE_MEMORY KEYBUFFER 1 0 FALSE
WRITE_MEMORY pFormText 4 0 FALSE
RETURN
Keyboard:
IF iTotalChars <= 10
READ_MEMORY KEYBUFFER 1 FALSE (iChar)
//after all, our buffer doesn't stores numpad
iChar = 0x60
WHILE iChar <= 0x69
IF IS_KEY_PRESSED iChar
iChar -= 0x30
GOSUB Keyboard_StoreOneKey
iChar += 0x30
WHILE IS_KEY_PRESSED iChar
GOSUB ProcessAndDrawInterface
ENDWHILE
RETURN
ENDIF
iChar++
ENDWHILE
IF NOT iChar = 0
AND iChar >= 0x30
AND iChar <= 0x39
GOSUB Keyboard_StoreOneKey
RETURN
ENDIF
ENDIF
IF IS_KEY_PRESSED VK_BACK
IF iTotalChars > 0
i = pFormText
i += iTotalChars
i--
WRITE_MEMORY i 1 0 FALSE
iTotalChars--
GOSUB Keyboard_UpdateGXT
WHILE IS_KEY_PRESSED VK_BACK
GOSUB ProcessAndDrawInterface
ENDWHILE
ENDIF
ENDIF
RETURN
Keyboard_StoreOneKey:
i = pFormText
i += iTotalChars
WRITE_MEMORY i 1 iChar FALSE
i++
WRITE_MEMORY i 1 0 FALSE
iTotalChars++
WRITE_MEMORY KEYBUFFER 1 0 FALSE
GOSUB Keyboard_UpdateGXT
RETURN
Keyboard_UpdateGXT:
IF pFormText > 0
GET_LABEL_POINTER FormTextScreen i
STRING_FORMAT i "$%s" pFormText
ADD_TEXT_LABEL _BCIVAL $i
CALL_FUNCTION_RETURN 0x822506 1 1 (pFormText)(i) //atoi
iFormValue = i
f =# i
f /= fPrice
GET_LABEL_POINTER BCIBTC i
STRING_FORMAT i "= BTC %.6f" f
ADD_TEXT_LABEL _BCIBTC $i
ELSE
ADD_TEXT_LABEL _BCIVAL "$"
ENDIF
RETURN
/////////////////////////////////////////////////
FormatText_Value:
SET_TEXT_WRAPX 640.0
SET_TEXT_SCALE 0.23 0.85
SET_TEXT_EDGE 1 0 0 0 255
SET_TEXT_FONT 2
SET_TEXT_COLOUR 255 255 255 255
RETURN
FormatText_Desc:
SET_TEXT_WRAPX 640.0
SET_TEXT_SCALE 0.2 0.8
SET_TEXT_EDGE 1 0 0 0 255
SET_TEXT_FONT 1
SET_TEXT_COLOUR 180 180 180 180
RETURN
FormatText_Credits:
SET_TEXT_WRAPX 640.0
SET_TEXT_SCALE 0.15 0.7
SET_TEXT_EDGE 1 0 0 0 255
SET_TEXT_FONT 1
SET_TEXT_COLOUR 180 180 180 150
RETURN
FormatText_BuySellValue:
SET_TEXT_WRAPX 640.0
SET_TEXT_SCALE 0.23 0.85
SET_TEXT_EDGE 1 0 0 0 255
SET_TEXT_FONT 2
SET_TEXT_PROPORTIONAL TRUE
SET_TEXT_COLOUR 255 255 255 255
RETURN
FormatText_BTCBuySellValue:
SET_TEXT_WRAPX 640.0
SET_TEXT_SCALE 0.15 0.7
SET_TEXT_EDGE 1 0 0 0 255
SET_TEXT_FONT 2
SET_TEXT_PROPORTIONAL TRUE
SET_TEXT_COLOUR 255 200 50 255
RETURN
FormatText_BuySellText:
SET_TEXT_WRAPX 640.0
SET_TEXT_SCALE 0.22 0.8
SET_TEXT_EDGE 1 0 0 0 255
SET_TEXT_FONT 2
SET_TEXT_COLOUR 255 255 255 255
RETURN
FormatText_BuySellCmd:
SET_TEXT_WRAPX 640.0
SET_TEXT_SCALE 0.22 0.83
SET_TEXT_EDGE 0 0 0 0 0
SET_TEXT_FONT 1
SET_TEXT_COLOUR 0 0 0 200
RETURN
FormatText_BalanceValue:
SET_TEXT_WRAPX 640.0
SET_TEXT_SCALE 0.18 0.75
SET_TEXT_EDGE 1 0 0 0 255
SET_TEXT_FONT 2
SET_TEXT_PROPORTIONAL TRUE
SET_TEXT_COLOUR 255 255 255 255
RETURN
}
SCRIPT_END
{
LVAR_INT var //In
LVAR_FLOAT value //In
LVAR_INT scriptSpace finalOffset
WriteGlobalFloatVar:
READ_MEMORY 0x00468D5E 4 1 (scriptSpace)
finalOffset = var * 4
finalOffset += scriptSpace
WRITE_MEMORY finalOffset 4 (value) FALSE
CLEO_RETURN 0 ()
}
{
LVAR_INT var //In
LVAR_INT scriptSpace finalOffset
LVAR_FLOAT value
ReadGlobalFloatVar:
READ_MEMORY 0x00468D5E 4 1 (scriptSpace)
finalOffset = var * 4
finalOffset += scriptSpace
READ_MEMORY finalOffset 4 FALSE (value)
CLEO_RETURN 0 (value)
}
{
LVAR_FLOAT x y // In
LVAR_FLOAT fresX fresY
LVAR_INT iresX iresY
GetXYSizeInScreen4x3ScaleBy640x480:
READ_MEMORY 0x00C17044 4 FALSE (iresX) // Get current resolution X
READ_MEMORY 0x00C17048 4 FALSE (iresY) // Y
fresX =# iresX
fresY =# iresY
fresY *= 1.33333333
fresX /= fresY
x /= fresX
y /= 1.07142857
CLEO_RETURN 0 (x y)
}
FormText:
DUMP
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ENDDUMP
FormTextScreen:
DUMP
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ENDDUMP
BCPRIC:
DUMP
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ENDDUMP
BCPR1H:
DUMP
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ENDDUMP
BCPR2H:
DUMP
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ENDDUMP
BCPR7D:
DUMP
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ENDDUMP
BCIBTC:
DUMP
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ENDDUMP
BCCBTC:
DUMP
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ENDDUMP
BCDOLL:
DUMP
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ENDDUMP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.