/createpayphone <-- Check this!
#1

Hey guys so Im creating a dynamic payphone command /createpayphone. The Savephone() writes to the file but for some reason its not loading them. Do you guys see an issue you here?


LOAD PHONE
Код:
LoadPhones()
{
//	new string[256];
    new arrCoords[4][64];
    new strFromFile2[260];
    new File: file = fopen("payphones.cfg", io_read);
    if(file)
    {
        new idx;
        while (idx < sizeof(PhoneInfo))
        {
            fread(file, strFromFile2);
            split(strFromFile2, arrCoords, '|');
            PhoneIDTaken[idx] = strval(arrCoords[0]);
            PhoneInfo[idx][PhoneX] = floatstr(arrCoords[1]);
            PhoneInfo[idx][PhoneY] = floatstr(arrCoords[2]);
            PhoneInfo[idx][PhoneZ] = floatstr(arrCoords[3]);
        	if(HouseIDTaken[idx])
        	{
				CreateStreamed3DTextLabel(PAYPHONE_LABEL, HOUSE_COLOR,PhoneInfo[idx][PhoneX],PhoneInfo[idx][PhoneY],PhoneInfo[idx][PhoneZ] , 10.0, idx);
                phones++;
			}
			idx++;
		}
	}
	return 1;
}
SAVE PHONE
Код:
SavePhones()
{
    new idx = 1;
    new File: file2;
    while (idx < sizeof(GarageInfo))
    {
        new coordsstring[256];
        format(coordsstring, sizeof(coordsstring), "|%d|%f|%f|%f|\n",
       	GarageIDTaken[idx],
   	   	PhoneInfo[idx][PhoneX],
	   	PhoneInfo[idx][PhoneY],
	   	PhoneInfo[idx][PhoneZ]);
     	if(idx == 0)
		{
			file2 = fopen("payphones.cfg", io_write);
		}
		else
		{
			file2 = fopen("payphones.cfg", io_append);
		}
		fwrite(file2, coordsstring);
		idx++;
		fclose(file2);
    }
    return 1;
}
COMMAND
Код:
   	if(strcmp(cmd, "/createphone", true) == 0)
	{
	    if(PlayerInfo[playerid][pAdmin] >= 1337)
	    {
	        new id = GetAvailableID(TYPE_PHONE);
			new Float:x, Float:y, Float:z;
			GetPlayerPos(playerid, x, y, z);
			PhoneIDTaken[id] = 1;
            PhoneInfo[id][PhoneX] = x;
            PhoneInfo[id][PhoneY] = y;
            PhoneInfo[id][PhoneZ] = z;
			SavePhones();
            CreateStreamed3DTextLabel(PAYPHONE_LABEL, HOUSE_COLOR, x, y, z, 10.0, 0);
		}
		return 1;
	}
Reply


Messages In This Thread
/createpayphone <-- Check this! - by hewittpro - 01.11.2013, 01:54
Re: /createpayphone <-- Check this! - by Jefff - 01.11.2013, 02:13
Re: /createpayphone <-- Check this! - by hewittpro - 01.11.2013, 02:15
Re: /createpayphone <-- Check this! - by Jefff - 01.11.2013, 02:17
Re: /createpayphone <-- Check this! - by hewittpro - 01.11.2013, 02:39
Re: /createpayphone <-- Check this! - by hewittpro - 01.11.2013, 10:47
Re: /createpayphone <-- Check this! - by Jefff - 01.11.2013, 15:13
Re: /createpayphone <-- Check this! - by BlackHorse - 01.11.2013, 15:47
Re: /createpayphone <-- Check this! - by hewittpro - 01.11.2013, 16:21
Re: /createpayphone <-- Check this! - by Jefff - 01.11.2013, 16:26

Forum Jump:


Users browsing this thread: 1 Guest(s)