AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Different size usage in nextmap.sma (https://forums.alliedmods.net/showthread.php?t=102368)

Hunter-Digital 09-01-2009 13:57

Different size usage in nextmap.sma
 
Here's the code from plugin_init() inside the nextmap.sma:
Quote:

new szString[32], szString2[32], szString3[8]

get_localinfo("lastmapcycle", szString, 31)
parse(szString, szString2, 31, szString3, 7)
g_pos = str_to_num(szString3)
get_cvar_string("mapcyclefile", g_mapCycle, 31)

if (!equal(g_mapCycle, szString2))
g_pos = 0 // mapcyclefile has been changed - go from first

readMapCycle(g_mapCycle, g_nextMap, 31)
set_cvar_string("amx_nextmap", g_nextMap)
format(szString3, 31, "%s %d", g_mapCycle, g_pos) // save lastmapcycle settings
set_localinfo("lastmapcycle", szString3)

The szString3 variable is defined with 8 cells but in the lower code is formated as 31 characters... and the weird thing is, the plugin compiles and works fine, it doesn't report any kind of errors what-so-ever... WHY ? O.o

I also needed that code for something else and tried to replace the variables exacly, but in my case, the server returns "Runtime error 5: memory usage" or something like that... O.o

Can someone explain this, I'm really confused =)

Exolent[jNr] 09-01-2009 14:07

Re: Different size usage in nextmap.sma
 
Quote:

Originally Posted by Hunter-Digital (Post 920137)
The szString3 variable is defined with 8 cells but in the lower code is formated as 31 characters... and the weird thing is, the plugin compiles and works fine, it doesn't report any kind of errors what-so-ever... WHY ? O.o

The compiler doesn't know that argument in the function is the length of the string.

Hunter-Digital 09-01-2009 14:34

Re: Different size usage in nextmap.sma
 
Neither does the server ? I said, no errors, but I rewrote it with different variables and gives an in-game error... but this one does not

Exolent[jNr] 09-01-2009 14:44

Re: Different size usage in nextmap.sma
 
Show the code you used.

Alka 09-01-2009 14:45

Re: Different size usage in nextmap.sma
 
That depends, if the string formated doesn't exceed the alocated size won't return any error...


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

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