AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] Problems encountered with read_args @ chat (https://forums.alliedmods.net/showthread.php?t=173681)

Excalibur.007 12-09-2011 05:28

[SOLVED] Problems encountered with read_args @ chat
 
Code:
static szArgs[32] read_args(szArgs, 31) remove_quotes(szArgs) static szArg1[32], szArg2[32], szArg3[32] parse(szArgs, szArg1, 31, szArg2, 31, szArg3, 32) new iValue = str_to_num(szArg2) if(equali(szArg1, "/deposit") || equali(szArg1, "deposit")) {     if(iValue > g_iAmmoPacks[player])     {         iValue = g_iAmmoPacks[player]     }     else if(equali(szArg2, "all"))     {         iValue = g_iAmmoPacks[player]         IsAll[player] = true     }         if(iValue <= 0 && !IsAll[player])     {         zp_colored_print(player, "Invalid amount entered!")         return PLUGIN_HANDLED     }         IsAll[player] = false     IsManual[player] = true         new iTemp = g_iBank[player]         g_iBank[player] += iValue         if(g_iBank[player] > iBankLimit)     {         zp_ammopacks_set(player, g_iAmmoPacks[player] + g_iBank[player] - iBankLimit)                 iValue = iBankLimit - iTemp                 g_iBank[player] = iBankLimit     }     else     {         zp_ammopacks_set(player, g_iAmmoPacks[player] - iValue)     }         g_iAmmoPacks[player] -= iValue         #if defined SQLX         Save_MySQL(player)     #else         Save_nVault(player)     #endif         zp_colored_print(player, "You've deposited^x04 %d^x01 ammo pack(s)", iValue) } else if(equali(szArg1, "/withdraw") || equali(szArg1, "withdraw")) {     if(iValue > g_iBank[player])     {         iValue = g_iBank[player]     }     else if(equali(szArg2, "all"))     {         iValue = g_iBank[player]         IsAll[player] = true     }         if(iValue <= 0 && !IsAll[player])     {         zp_colored_print(player, "Invalid amount entered!")         return PLUGIN_HANDLED     }         IsAll[player] = false     IsManual[player] = true         zp_ammopacks_set(player, g_iAmmoPacks[player] + iValue)         g_iBank[player] -= iValue     g_iAmmoPacks[player] += iValue         #if defined SQLX         Save_MySQL(player)     #else         Save_nVault(player)     #endif         zp_colored_print(player, "You've withdrawn^x04 %d^x01 ammo pack(s)", iValue) }

There's an check if szArg2 is "all" and it worked but I found out that typing "/deposit", "deposit", "/withdraw" or "withdraw" without having the "all" argument on it.

Example:
Player 1 has 6 Points
Player 1 types "/deposit all" and the 6 points are stored.
Player 1 then types "/withdraw" and the 6 points are retrieved but without having "all" on the second argument.

EDIT: Another bug, after typing any of the commands stated above and I enter a blank space on the chat, it also calls the function like withdraw or deposit.

EDIT2: Nvm, I've fixed it. I just have to reset the arguments before parsing and it works now. Sorry for posting this.


All times are GMT -4. The time now is 12:11.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.