Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

Toy saving and loading problem

$
0
0
Hey guys,

I worked on a toy system, but I don't get what is wrong iwth this but I had finished working on it, tested it and it has problems loading and saving the system's, like I don't get what's wrong with it and it won't work properly, and gives me a lot of errors, not sure what is going on, here is the code:

Loading player stats:
Code:

for(new x = 0; x <= 12; x++)
            {
                        format(bstring, sizeof(bstring), "Bone_%d", x);
            PlayerToyInfo[playerid][x][ptBone] = cache_get_field_content_int(0, bstring);
            format(modelstring, sizeof(modelstring), "Model_%d", x);
                        PlayerToyInfo[playerid][x][ptModelID] = cache_get_field_content_int(0, modelstring);
                       
                        format(posxstring, sizeof(posxstring), "PosX_%d", x);
                        PlayerToyInfo[playerid][x][ptPosX] = cache_get_field_content_int(0, posxstring);
                        format(posystring, sizeof(posystring), "PosY_%d", x);
                        PlayerToyInfo[playerid][x][ptPosY] = cache_get_field_content_int(0, posystring);
                        format(poszstring, sizeof(poszstring), "PosZ_%d", x);
                        PlayerToyInfo[playerid][x][ptPosZ] = cache_get_field_content_int(0, poszstring);
                        format(rotxstring, sizeof(rotxstring), "RotX_%d", x);
                        PlayerToyInfo[playerid][x][ptRotX] = cache_get_field_content_int(0, rotxstring);
                        format(rotystring, sizeof(rotystring), "RotY_%d", x);
                        PlayerToyInfo[playerid][x][ptRotY] = cache_get_field_content_int(0, rotystring);
                        format(rotzstring, sizeof(rotzstring), "RotZ_%d", x);
                        PlayerToyInfo[playerid][x][ptRotZ] = cache_get_field_content_int(0, rotzstring);
                        format(scaxstring, sizeof(scaxstring), "ScaX_%d", x);
                        PlayerToyInfo[playerid][x][ptScaleX] = cache_get_field_content_int(0, scaxstring);
                        format(scaystring, sizeof(scaystring), "ScaY_%d", x);
                        PlayerToyInfo[playerid][x][ptScaleY] = cache_get_field_content_int(0, scaystring);
                        format(scazstring, sizeof(scazstring), "ScaZ_%d", x);
                        PlayerToyInfo[playerid][x][ptScaleZ] = cache_get_field_content_int(0, scazstring);
                       
                }


Saving player stats:
Code:

for(new x = 0; x <= 12; x++)
        {
                format(bstring, sizeof(bstring), "Bone_%d", x);
                format(modelstring, sizeof(modelstring), "Model_%d", x);
               
                format(Query, sizeof(Query), "UPDATE `playerdata` SET `%s` = %d, `%s` = %d WHERE `nick` = '%s' LIMIT 1",
                bstring,
                PlayerToyInfo[playerid][x][ptBone],
                modelstring,
                PlayerToyInfo[playerid][x][ptModelID],
                PlayerInfo[playerid][Nick]);
                mysql_tquery(mysql, Query, "", "");

        format(posxstring, sizeof(posxstring), "PosX_%d", x);
                format(posystring, sizeof(posystring), "PosY_%d", x);
                format(poszstring, sizeof(poszstring), "PosZ_%d", x);
                format(rotxstring, sizeof(rotxstring), "RotX_%d", x);
                format(rotystring, sizeof(rotystring), "RotY_%d", x);
                format(rotzstring, sizeof(rotzstring), "RotZ_%d", x);
                format(scaxstring, sizeof(scaxstring), "ScaX_%d", x);
                format(scaystring, sizeof(scaystring), "ScaY_%d", x);
                format(scazstring, sizeof(scazstring), "ScaZ_%d", x);
                format(Query, sizeof(Query), "UPDATE `playerdata` SET `%s` = %f, `%s` = %f, `%s` = %f, `%s` = %f, `%s` = %f, `%s` = %f, `%s` = %f, `%s` = %f WHERE `nick` = '%s' LIMIT 1",
                posxstring,
                PlayerToyInfo[playerid][x][ptPosX],
                posystring,
                PlayerToyInfo[playerid][x][ptPosY],
                poszstring,
                PlayerToyInfo[playerid][x][ptPosZ],
                rotxstring,
                PlayerToyInfo[playerid][x][ptRotX],
                rotystring,
                PlayerToyInfo[playerid][x][ptRotY],
                rotzstring,
                PlayerToyInfo[playerid][x][ptRotZ],
                scaxstring,
                PlayerToyInfo[playerid][x][ptScaleX],
                scaystring,
                PlayerToyInfo[playerid][x][ptScaleY],
                scazstring,
                PlayerToyInfo[playerid][x][ptScaleZ],
                PlayerInfo[playerid][Nick]);
                mysql_tquery(mysql, Query, "", "");
        }


Errors from the .exe (debug):
Code:

[17:56:38] [debug] Run time error 4: "Array index out of bounds"
[17:56:38] [debug] AMX backtrace:
[17:56:38] [debug] #0 000d5994 in public OnAccountLoad (playerid=0) at C:\Users\SugaryJesus\Desktop\Sapphire Gaming\SA-MP Server Files\Sever Files\gamemodes\bcrp-b2.pwn:6840
[18:02:26] [debug] Run time error 4: "Array index out of bounds"
[18:02:26] [debug] AMX backtrace:
[18:02:26] [debug] #0 000da414 in SavePlayer (playerid=0) at C:\Users\SugaryJesus\Desktop\Sapphire Gaming\SA-MP Server Files\Sever Files\gamemodes\bcrp-b2.pwn:7085
[18:02:26] [debug] #1 000a5bb8 in public SSCANF_OnPlayerDisconnect (playerid=0, reason=1) at C:\Users\SugaryJesus\Desktop\Sapphire Gaming\SA-MP Server Files\Sever Files\gamemodes\bcrp-b2.pwn:2289
[18:02:26] [debug] #2 0003e698 in public _y_utils_OnPlayerDisconnect (playerid=0, reason=1) at C:\Users\SugaryJesus\Desktop\Sapphire Gaming\SA-MP Server Files\Sever Files\pawno\include\sscanf2.inc:260
[18:02:26] [debug] #3 000099cc in OnPlayerDisconnect (playerid=0, reason=1, ... <1073741821 arguments>) at C:\Users\SugaryJesus\Desktop\Sapphire Gaming\SA-MP Server Files\Sever Files\pawno\include\YSI\..\YSI_Storage\..\YSI_Core\y_utils.inc:254
[18:02:26] [debug] #4 0000c0f8 in public OnPlayerDisconnect (... <2 arguments>) at C:\Users\SugaryJesus\Desktop\Sapphire Gaming\SA-MP Server Files\Sever Files\pawno\include\YSI\..\YSI_Storage\..\YSI_Coding\..\YSI_Internal\y_cgen.inc:30
[18:02:26] [part] Blaine_McGregor has left the server (0:1)


Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>