[Help] cache_get_data errors!
#1

I am not sureof why I am getting the errors and what's causing them. If anyone could help me fix the errors I would be very thankful!

Код:
forward LoadGlobalObjects();
public LoadGlobalObjects();

	new rows, fields;
	cache_get_data(rows, fields);
(125)	for(new i = 0; i < rows; i ++)
	{
(127)	    if(cache_get_field_content_int(i, "PlayerObjectStatus") == 4)
	    {
(129)           RemoveObjectFromDatabase(cache_get_field_content_int(i, "PID"), true);
            continue;
		}
            
(133)	    GlobalObject[i][PlayerID] = cache_get_field_content_int(i, "PID");
	    GlobalObject[i][RealID] = cache_get_field_content_int(i, "ID");
	    
	    new temp[32];
	    cache_get_field_content(i, "Name", temp);
	    format(GlobalObject[i][O_Name], 32, "%s", temp);
	    
        GlobalObject[i][Size] = cache_get_field_content_int(i, "H_Size");
        GlobalObject[i][TypeID] = cache_get_field_content_int(i, "TypeID");
        GlobalObject[i][Carry] = cache_get_field_content_int(i, "Carry");
        GlobalObject[i][Display] = cache_get_field_content_int(i, "Display");
        GlobalObject[i][Position] = cache_get_field_content_int(i, "Position");
        GlobalObject[i][Status] = cache_get_field_content_int(i, "PlayerObjectStatus");
        GlobalObject[i][WorldX] = cache_get_field_content_float(i, "WorldX");
        GlobalObject[i][WorldY] = cache_get_field_content_float(i, "WorldY");
        GlobalObject[i][WorldZ] = cache_get_field_content_float(i, "WorldZ");

		GlobalObject[i][GameObject] = CreateDynamicObject(GlobalObject[i][Display], GlobalObject[i][WorldX], GlobalObject[i][WorldY], GlobalObject[i][WorldZ], 0.0, 0.0, 0.0);
		GlobalObject[i][AreaID] = CreateDynamicRectangle(GlobalObject[i][WorldX]-1, GlobalObject[i][WorldY]-1, GlobalObject[i][WorldX]+1, GlobalObject[i][WorldY]+1);
	}
	print("[INVENTORY SUCCESS]: Loaded all the global objects.");
	return 1;
}
Here are the errors I get.
//---------------------//

inventory.pwn(124) : warning 219: local variable "rows" shadows a variable at a preceding level
inventory.pwn(124) : warning 219: local variable "fields" shadows a variable at a preceding level
inventory.pwn(125) : error 010: invalid function or declaration
inventory.pwn(127) : error 010: invalid function or declaration
inventory.pwn(129) : error 017: undefined symbol "i"
inventory.pwn(129) : error 010: invalid function or declaration
inventory.pwn(129 -- 133) : error 010: invalid function or declaration
inventory.pwn(129 -- 133) : fatal error 107: too many error messages on one line
Reply
#2

You have a semicolon behind your "public" line which shouldn't be there, and a missing opening brace on the line right underneath it.
Reply
#3

So you don't have to do "forward function();" and then "public function()". Add this on top of your gamemode:
pawn Код:
#define function%0(%1) forward%0(%1); public%0(%1)
Here's your function:
pawn Код:
function LoadGlobalObjects()
{
    new rows, fields;
    cache_get_data(rows, fields);
    for(new i = 0; i < rows; i ++)
    {
        if(cache_get_field_content_int(i, "PlayerObjectStatus") == 4)
        {
            RemoveObjectFromDatabase(cache_get_field_content_int(i, "PID"), true);
            continue;
        }
        GlobalObject[i][PlayerID] = cache_get_field_content_int(i, "PID");
        GlobalObject[i][RealID] = cache_get_field_content_int(i, "ID");
        new temp[32];
        cache_get_field_content(i, "Name", temp);
        format(GlobalObject[i][O_Name], 32, "%s", temp);
        GlobalObject[i][Size] = cache_get_field_content_int(i, "H_Size");
        GlobalObject[i][TypeID] = cache_get_field_content_int(i, "TypeID");
        GlobalObject[i][Carry] = cache_get_field_content_int(i, "Carry");
        GlobalObject[i][Display] = cache_get_field_content_int(i, "Display");
        GlobalObject[i][Position] = cache_get_field_content_int(i, "Position");
        GlobalObject[i][Status] = cache_get_field_content_int(i, "PlayerObjectStatus");
        GlobalObject[i][WorldX] = cache_get_field_content_float(i, "WorldX");
        GlobalObject[i][WorldY] = cache_get_field_content_float(i, "WorldY");
        GlobalObject[i][WorldZ] = cache_get_field_content_float(i, "WorldZ");
        GlobalObject[i][GameObject] = CreateDynamicObject(GlobalObject[i][Display], GlobalObject[i][WorldX], GlobalObject[i][WorldY], GlobalObject[i][WorldZ], 0.0, 0.0, 0.0);
        GlobalObject[i][AreaID] = CreateDynamicRectangle(GlobalObject[i][WorldX]-1, GlobalObject[i][WorldY]-1, GlobalObject[i][WorldX]+1, GlobalObject[i][WorldY]+1);
    }
    print("[INVENTORY SUCCESS]: Loaded all the global objects.");
    return 1;
}
Reply
#4

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
So you don't have to do "forward function();" and then "public function()". Add this on top of your gamemode:
pawn Код:
#define function%0(%1) forward%0(%1); public%0(%1)
Here's your function:
pawn Код:
function LoadGlobalObjects()
{
    new rows, fields;
    cache_get_data(rows, fields);
    for(new i = 0; i < rows; i ++)
    {
        if(cache_get_field_content_int(i, "PlayerObjectStatus") == 4)
        {
            RemoveObjectFromDatabase(cache_get_field_content_int(i, "PID"), true);
            continue;
        }
        GlobalObject[i][PlayerID] = cache_get_field_content_int(i, "PID");
        GlobalObject[i][RealID] = cache_get_field_content_int(i, "ID");
        new temp[32];
        cache_get_field_content(i, "Name", temp);
        format(GlobalObject[i][O_Name], 32, "%s", temp);
        GlobalObject[i][Size] = cache_get_field_content_int(i, "H_Size");
        GlobalObject[i][TypeID] = cache_get_field_content_int(i, "TypeID");
        GlobalObject[i][Carry] = cache_get_field_content_int(i, "Carry");
        GlobalObject[i][Display] = cache_get_field_content_int(i, "Display");
        GlobalObject[i][Position] = cache_get_field_content_int(i, "Position");
        GlobalObject[i][Status] = cache_get_field_content_int(i, "PlayerObjectStatus");
        GlobalObject[i][WorldX] = cache_get_field_content_float(i, "WorldX");
        GlobalObject[i][WorldY] = cache_get_field_content_float(i, "WorldY");
        GlobalObject[i][WorldZ] = cache_get_field_content_float(i, "WorldZ");
        GlobalObject[i][GameObject] = CreateDynamicObject(GlobalObject[i][Display], GlobalObject[i][WorldX], GlobalObject[i][WorldY], GlobalObject[i][WorldZ], 0.0, 0.0, 0.0);
        GlobalObject[i][AreaID] = CreateDynamicRectangle(GlobalObject[i][WorldX]-1, GlobalObject[i][WorldY]-1, GlobalObject[i][WorldX]+1, GlobalObject[i][WorldY]+1);
    }
    print("[INVENTORY SUCCESS]: Loaded all the global objects.");
    return 1;
}
Thanks for your help! but..it appears I am still having troubles with these errors..

inventory.pwn(124) : error 012: invalid function call, not a valid address
inventory.pwn(124) : warning 215: expression has no effect
inventory.pwn(124) : warning 215: expression has no effect
inventory.pwn(124) : error 001: expected token: ";", but found ")"
inventory.pwn(124) : error 029: invalid expression, assumed zero
inventory.pwn(124) : fatal error 107: too many error messages on one line
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)