GangZone Loader not working
#1

I've tried to make myself a gang zone loader, but its not working, when I go on the server and spawn the gangzones aren't there.

This is the code, I probably did something wrong ;P

OnPlayerSpawn
Код:
	for(new i; i<MAX_ZONES; i++)
	{
	  GangZoneShowForPlayer(playerid,pTurf[i][ID],GetTeamColor(pTurf[i][Team]));
	}
LoadZones:
Код:
stock LoadZones()
{
	if(fexist("TurfZones/turfs.ini"))
	{
	  new entry[256];
		new Argument[9][70];
		new File: turffile = fopen("TurfZones/turfs.ini", io_read);
	  if (turffile)
		{
		  for(new i; i<MAX_ZONES; i++)
			{
				fread(turffile, entry);
				pTurf[i][ID] = strval(Argument[0]);
				pTurf[i][minx] = floatstr(Argument[1]);
				pTurf[i][miny] = floatstr(Argument[2]);
				pTurf[i][maxx] = floatstr(Argument[3]);
				pTurf[i][maxy] = floatstr(Argument[4]);
				pTurf[i][Team] = strval(Argument[5]);
				pTurf[i][ID] = GangZoneCreate(pTurf[i][minx],pTurf[i][miny],pTurf[i][maxx],pTurf[i][maxy]);
				fclose(turffile);
		}
	}
}
}
Reply
#2

Bump..

Still having the problem, I cant seem to fix it.
Reply
#3

You're closing the file, before you could even read the second line
Reply
#4

Try
pawn Код:
stock LoadZones()
{
    if(fexist("TurfZones/turfs.ini"))
    {
        new entry[256];
        new Argument[9][70];
        new File: turffile = fopen("TurfZones/turfs.ini", io_read);
        if (turffile)
        {
            for(new i; i<MAX_ZONES; i++)
            {
                fread(turffile, entry);
                pTurf[i][ID] = strval(Argument[0]);
                pTurf[i][minx] = floatstr(Argument[1]);
                pTurf[i][miny] = floatstr(Argument[2]);
                pTurf[i][maxx] = floatstr(Argument[3]);
                pTurf[i][maxy] = floatstr(Argument[4]);
                pTurf[i][Team] = strval(Argument[5]);
                pTurf[i][ID] = GangZoneCreate(pTurf[i][minx],pTurf[i][miny],pTurf[i][maxx],pTurf[i][maxy]);
            }
            fclose(turffile);
        }
    }
}
Reply
#5

You're trying to read from "Argument" but it's empty, "entry" is the string which stores the data from the file, look at the 'fread' line.
Reply
#6

Quote:
Originally Posted by lrZ^ aka LarzI
Try
pawn Код:
stock LoadZones()
{
    if(fexist("TurfZones/turfs.ini"))
    {
        new entry[256];
        new Argument[9][70];
        new File: turffile = fopen("TurfZones/turfs.ini", io_read);
        if (turffile)
        {
            for(new i; i<MAX_ZONES; i++)
            {
                fread(turffile, entry);
                pTurf[i][ID] = strval(Argument[0]);
                pTurf[i][minx] = floatstr(Argument[1]);
                pTurf[i][miny] = floatstr(Argument[2]);
                pTurf[i][maxx] = floatstr(Argument[3]);
                pTurf[i][maxy] = floatstr(Argument[4]);
                pTurf[i][Team] = strval(Argument[5]);
                pTurf[i][ID] = GangZoneCreate(pTurf[i][minx],pTurf[i][miny],pTurf[i][maxx],pTurf[i][maxy]);
            }
            fclose(turffile);
        }
    }
}
Still doesn't work.

Quote:
Originally Posted by Donny
You're trying to read from "Argument" but it's empty, "entry" is the string which stores the data from the file, look at the 'fread' line.
Care to explain more?
Reply
#7

He means how do you get data into the "Argument" array
Reply
#8

Quote:
Originally Posted by dice7
He means how do you get data into the "Argument" array
Код:
stock LoadZones()
{
	if(fexist("TurfZones/turfs.ini"))
	{
	  	new entry[256];
			new Argument[9][70];
			new File: turffile = fopen("TurfZones/turfs.ini", io_read);
	  		if (turffile)
		{
		  	for(new i; i<MAX_ZONES; i++)
			{
				fread(turffile, entry);
				split(entry, Argument, ',');
				pTurf[i][ID] = strval(Argument[0]);
				pTurf[i][minx] = floatstr(Argument[1]);
				pTurf[i][miny] = floatstr(Argument[2]);
				pTurf[i][maxx] = floatstr(Argument[3]);
				pTurf[i][maxy] = floatstr(Argument[4]);
				pTurf[i][Team] = strval(Argument[5]);
				pTurf[i][ID] = GangZoneCreate(pTurf[i][minx],pTurf[i][miny],pTurf[i][maxx],pTurf[i][maxy]);
			}
				fclose(turffile);
		}
	}
}
that's my updated code, I'm using the split thing to get the data into the argument array,

It loads them now, but they're not positioned right and they're the wrong color than what they should be :S

(I'm using http://forum.sa-mp.com/index.php?topic=14702.0 to get the minx miny maxx and maxy, and using GetTeamColor to load the color from the team array from the turfs file.)
Reply
#9

Quote:
Originally Posted by Seif_
Use this:
http://forum.sa-mp.com/index.php?topic=109726.0
You can even check how it saves and loads properly.
Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)