Jump to content
  • 0

Safe deposit bug


gunskill

Question

Buna ziua am o problema la /fmats /fdrugs nu pot sa le folosesc pentru ca zice ca nu sunt la locul potrivit

am vazut ca din scriptfiles imi lipseste factions.cfg e oare de acolo?

please help

if(strcmp(cmd, "/fdrugs", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        if(IsAMember(playerid))
	        {
				new x;
				x = PlayerInfo[playerid][pMember] + PlayerInfo[playerid][pLeader];
	            if(PlayerInfo[playerid][pRank] < 3)
	            {
	                SCM(playerid, COLOR_GREY, "   You need to be Rank 2 or Higher for this action !");
	                return 1;
	            }
	            /*if(DynamicFactions[x][fSafe] <= 0)
				{
					SCM(playerid, COLOR_WHITE, "The leader must buy a SAFE first !");
					return 1;
				}*/
	            new x_nr[256];
				x_nr = strtok(cmdtext, idx);
				if(!strlen(x_nr))
				{
					if(PTP(5.0,playerid,DynamicFactions[x][fX],DynamicFactions[x][fY],DynamicFactions[x][fZ]))
					{
						format(string, sizeof(string), "Faction Drugs: $%d.", DynamicFactions[x][fDrugs]);
						SCM(playerid, COLOR_WHITE, string);
					}
					SCM(playerid, COLOR_WHITE, "|______________________FactionsDrugs___________________|");
					SCM(playerid, COLOR_WHITE, "| USAGE: /fdrugs [name] [ammount]");
			  		SCM(playerid, COLOR_GREY, " | Available names: Take , Put");
					SCM(playerid, COLOR_WHITE, "|______________________________________________________|");
					return 1;
				}
				GetPlayerName(playerid, sendername, sizeof(sendername));
				GetPlayerName(giveplayerid, playername, sizeof(playername));
			    if(strcmp(x_nr,"take",true) == 0)
				{
					tmp = strtok(cmdtext, idx);
					if(!strlen(tmp))
					{
						SCM(playerid, COLOR_GREY, "[USAGE:] /fdrugs take [amount]");
						return 1;
					}
					new materialsdeposit = strval(tmp);
					if(!strlen(tmp))
					{
						SCM(playerid, COLOR_GREY, "[USAGE:] /fdrugs take [amount]");
						return 1;
					}
					if(PTP(5.0,playerid,DynamicFactions[x][fX],DynamicFactions[x][fY],DynamicFactions[x][fZ]))
					{
					    if(materialsdeposit <=DynamicFactions[x][fDrugs])
					    {
							PlayerInfo[playerid][pDrugs] += materialsdeposit;
							DynamicFactions[x][fDrugs]=DynamicFactions[x][fDrugs]-materialsdeposit;
							format(string, sizeof(string), "You have taken %d drugs from the storage facility, Drugs Total: %d ", materialsdeposit,DynamicFactions[x][fDrugs]);
							SCM(playerid, COLOR_LIGHTBLUE, string);
							format(string, sizeof(string),  "%s has just taken %d drugs from the faction storage facility.",sendername,materialsdeposit);
							SendFamilyMessage(x, TEAM_AZTECAS_COLOR, string);
							SaveDynamicFactions();
							return 1;
						}
			 			else
						{
							SCM(playerid, COLOR_GREY, "There isn't that much drugs in storage!");
						}
					}
					else
					{
						SCM(playerid, COLOR_GREY	, "You are not at the faction storage facility!");
					}
				}
    			else if(strcmp(x_nr,"put",true) == 0)
				{
					tmp = strtok(cmdtext, idx);
					if(!strlen(tmp))
					{
						SCM(playerid, COLOR_GREY, "[USAGE:] /fdrugs put [amount]");
						return 1;
					}
					new materialsdeposit = strval(tmp);
					if(!strlen(tmp))
					{
						SCM(playerid, COLOR_GREY, "[USAGE:] /fdrugs put [amount]");
						return 1;
					}
					if(PTP(5.0,playerid,DynamicFactions[x][fX],DynamicFactions[x][fY],DynamicFactions[x][fZ]))
					{
					    if(materialsdeposit <= PlayerInfo[playerid][pDrugs])
					    {
							PlayerInfo[playerid][pDrugs] =PlayerInfo[playerid][pDrugs]-materialsdeposit;
							DynamicFactions[x][fDrugs] +=materialsdeposit;
							format(string, sizeof(string), "You putted %d drugs from the storage facility, Drugs Total: %d ", materialsdeposit,DynamicFactions[x][fDrugs]);
							SCM(playerid, COLOR_LIGHTBLUE, string);
							format(string, sizeof(string),  "%s has just putted %d drugs from the faction storage facility.",sendername,materialsdeposit);
							SendFamilyMessage(x, TEAM_AZTECAS_COLOR, string);
							SaveDynamicFactions();
							return 1;
						}
			 			else
						{
							SCM(playerid, COLOR_GREY, "You don't have that much drugs on you!");
						}
					}
					else
					{
						SCM(playerid, COLOR_GREY, "You are not at the faction storage facility!");
					}
				}
				else
				{
					SCM(playerid, COLOR_GREY, "Unknown fDrugs name !");
					return 1;
				}
	        }
	        else
	        {
	            SCM(playerid, COLOR_GREY, "You are not a gang member !");
	            return 1;
	        }
	    }
	    return 1;
	}
public LoadDynamicFactions()
{
	new arrCoords[8][64];
	new strFromFile2[256];
	new File: file = fopen("factions.cfg", io_read);
	if (file)
	{
		new idx;
		while (idx < sizeof(DynamicFactions))
		{
			fread(file, strFromFile2);
			split(strFromFile2, arrCoords, '|');
			strmid(DynamicFactions[idx][fName], arrCoords[0], 0, strlen(arrCoords[0]), 255);
			DynamicFactions[idx][fX] = floatstr(arrCoords[1]);
			DynamicFactions[idx][fY] = floatstr(arrCoords[2]);
			DynamicFactions[idx][fZ] = floatstr(arrCoords[3]);
			DynamicFactions[idx][fMats] = strval(arrCoords[4]);
			DynamicFactions[idx][fDrugs] = strval(arrCoords[5]);
			DynamicFactions[idx][fBank] = strval(arrCoords[6]);
			DynamicFactions[idx][fSafe] = strval(arrCoords[7]);
			printf("[FACTIONS]: Name:%s, ID:%d, Mats:%d, Drugs:%d, Money:%d",DynamicFactions[idx][fName],idx,DynamicFactions[idx][fMats],DynamicFactions[idx][fDrugs],DynamicFactions[idx][fBank],DynamicFactions[idx][fSafe]);
			idx++;
		}
		fclose(file);
	}
	return 1;
}

public SaveDynamicFactions()
{
	new idx;
	new File: file2;
	while (idx < sizeof(DynamicFactions))
	{

		new coordsstring[512];
		format(coordsstring, sizeof(coordsstring), "%s|%f|%f|%f|%d|%d\n",
		DynamicFactions[idx][fName],
		DynamicFactions[idx][fX],
		DynamicFactions[idx][fY],
		DynamicFactions[idx][fZ],
		DynamicFactions[idx][fMats],
		DynamicFactions[idx][fDrugs],
		DynamicFactions[idx][fBank],
        DynamicFactions[idx][fSafe]);

		if(idx == 0)
		{
			file2 = fopen("factions.cfg", io_write);
		}
		else
		{
			file2 = fopen("factions.cfg", io_append);
		}
		fwrite(file2, coordsstring);
		idx++;
		fclose(file2);
	}
	return 1;
}

rszadc33936a6e246e39ea2.png
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.