AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Bug Plugin (https://forums.alliedmods.net/showthread.php?t=242792)

Zeroxz 06-24-2014 17:43

[HELP] Bug Plugin
 
Solucionado

Flick3rR 06-24-2014 17:59

Re: [HELP] Bug Plugin
 
Attach the code as a .sma file, because this one is bad indented.

Black Rose 06-24-2014 18:09

Re: [HELP] Bug Plugin
 
The thing with menu_additem is that all the values are saved behind the scenes in the form of bytes instead of cells (4 bytes).
If signed that means -128 to 127, and unsigned 0 to 255. PAWN doesn't have unsigned values.
You either lower the price, bit shift the value into multiple cells or convert it to a string.

I prefer the bitshifting because it's a predefined size that doesn't require parsing by natives, but it is also the most complicated one.

But performance is not an issue in the case of menus, you can just make it a string. Your data variable is already 5 cells, which is enough for 4 numbers and null.

Here's how to do it with strings:
Code:
Data[0] = CONST_MENU_DATA[i][mPRICE]
-->
Code:
num_to_str(CONST_MENU_DATA[i][mPRICE], Data, charsmax(Data));


Code:
if(g_Frags[id] < Data[0])
-->
Code:
if(g_Frags[id] < str_to_num(Data))


Code:
g_Frags[id] -= Data[0]
-->
Code:
g_Frags[id] -= str_to_num(Data)




Edit:
You could also apply the same logic as done with the hitzone string message
Code:
client_print(id, print_chat, "Raz3r.- Ahora haces danio en %s", CONST_MENU_DATA[item][mHITZONE])
Since "item" will match the array enumeration, you could use that for the frags cost as well.
This would be the preferred method as it saves all the getinfo native calls.

Zeroxz 06-24-2014 18:15

Re: [HELP] Bug Plugin
 
string as I do?


All times are GMT -4. The time now is 21:13.

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