Raised This Month: $ Target: $400
 0% 

[SOLVED] Problems encountered with read_args @ chat


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Excalibur.007
Veteran Member
Join Date: Sep 2009
Location: Singapore
Old 12-09-2011 , 05:28   [SOLVED] Problems encountered with read_args @ chat
Reply With Quote #1

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.

Last edited by Excalibur.007; 12-09-2011 at 05:43.
Excalibur.007 is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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