[Ajuda] Problema com comando /despejar
#1

@resolvido VLWZ
Reply
#2

Cara tenho esse comando no GM testa ae faz um backup do seu GM antes de fazer alteraзхes =S porque depois se der errado pelomenos nгo sai com o gm pior que tava =S


Despejar

pawn Код:
if(strcmp(cmd, "/despejar", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new borse = PlayerInfo[playerid][pPHousekey];
            GetPlayerName(playerid, playername, sizeof(playername));
            if (borse != 255 && strcmp(playername, HouseInfo[PlayerInfo[playerid][pPHousekey]][hOwner], true) == 0)
            {
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "USE: /despejar [id]");
                }
                new target;
                //target = strval(tmp);
                target = ReturnUser(tmp);
                if (target == playerid)
                {
                    SendClientMessage(target, COLOR_WHITE, "Vocк nгo pode despejar a si mesmo.");
                    return true;
                }
                if(IsPlayerConnected(target))
                {
                    if(target != INVALID_PLAYER_ID)
                    {
                        if(PlayerInfo[target][pPHousekey] == PlayerInfo[playerid][pPHousekey])
                        {
                            SendClientMessage(target, COLOR_WHITE, "Vocк foi despejado");
                            SendClientMessage(playerid, COLOR_WHITE, "Vocк despejou o jogador");
                            PlayerInfo[target][pPHousekey] = 255;
                            return true;
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOR_WHITE, "O Jogador nгo alugou sua casa !");
                            return true;
                        }
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD2, "   Vocк nгo й dono de uma casa !");
                return true;
            }
        }
        return true;
    }

Despejar TODOS

pawn Код:
if(strcmp(cmd, "/despejartodos", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new borse = PlayerInfo[playerid][pPHousekey];
            if (borse != 255 && strcmp(playername, HouseInfo[PlayerInfo[playerid][pPHousekey]][hOwner], true) == 0)
            {
                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnected(i))
                    {
                        if(i != playerid)
                        {
                            if (PlayerInfo[i][pPHousekey] == PlayerInfo[playerid][pPHousekey] )
                            {
                                SendClientMessage(i, COLOR_WHITE, "Vocк foi despejado de sua casa.");
                                SendClientMessage(playerid, COLOR_WHITE, "Vocк expulsou todos os inquilinos de sua casa.");
                                PlayerInfo[i][pPHousekey] = 255;
                                return true;
                            }
                        }
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD2, "   Vocк nгo й dono de uma casa !");
                return true;
            }
        }
        return true;
    }
Reply
#3

Adicione isto na INCLUDE PPC_comon.inc
Код:
// This function will evict the given house from the server and from the owner's account (if it has an owner)
House_Evict(HouseID)
{
	// Setup local variables
	new Msg[128], Name[24], bool:PlayerOnline = false;

	// Check if the house is owned
	if (AHouseData[HouseID][Owned] == true)
	{
		// Loop through all players to find the owner (if he's online)
		for (new pid; pid < MAX_PLAYERS; pid++)
		{
			// Check if this player is online
		    if (IsPlayerConnected(pid))
		    {
		        // Get that player's name
		        GetPlayerName(pid, Name, sizeof(Name));
		        // Compare if this player has the same name as the owner of the house
				if (strcmp(AHouseData[HouseID][Owner], Name, false) == 0)
				{
				    // Set PlayerOnline to "true"
				    PlayerOnline = true;

					// Inform the player that his house is being deleted
					format(Msg, 128, "{FF0000}Your house {FFFF00}\"%s\"{FF0000} is being deleted", AHouseData[HouseID][HouseName]);
					SendClientMessage(pid, 0xFFFFFFFF, Msg);

					// Also remove the HouseID from his list of houses
					for (new HouseSlot; HouseSlot < MAX_HOUSESPERPLAYER; HouseSlot++)
					    // Check if the house is stored in this houseslot
					    if (APlayerData[pid][Houses][HouseSlot] == HouseID)
					        // If the house is stored in this slot, clear the slot
					        APlayerData[pid][Houses][HouseSlot] = 0;

					// Save the player's account again
					PlayerFile_Save(pid);

					// Stop this For-loop, as the owner was already found and informed
					break;
				}
		    }
		}

		// Check if the player was not online
		if (PlayerOnline == false)
			// Remove the house from the player's account (open the account, remove the data and re-save it)
			PlayerFile_RemoveProperty(AHouseData[HouseID][Owner], HouseID, 0);
	}

	// First remove all vehicles from the house
	House_RemoveVehicles(HouseID);

	// Clear ownership of the house
	AHouseData[HouseID][Owned] = false;
	AHouseData[HouseID][Owner] = 0;

	// Update the entrance of the house
	House_UpdateEntrance(HouseID);

	// Save the housefile
	HouseFile_Save(HouseID);
}


// This function will evict the given business from the server and from the owner's account (if it has an owner)
Business_Evict(BusID)
{
	// Setup local variables
	new Msg[128], Name[24], bool:PlayerOnline = false;

	// Check if the business is owned
	if (ABusinessData[BusID][Owned] == true)
	{
		// Loop through all players to find the owner (if he's online)
		for (new pid; pid < MAX_PLAYERS; pid++)
		{
			// Check if this player is online
		    if (IsPlayerConnected(pid))
		    {
		        // Get that player's name
		        GetPlayerName(pid, Name, sizeof(Name));
		        // Compare if this player has the same name as the owner of the business
				if (strcmp(ABusinessData[BusID][Owner], Name, false) == 0)
				{
				    // Set PlayerOnline to "true"
				    PlayerOnline = true;

					// Inform the player that his business is being deleted
					format(Msg, 128, "{FF0000}Your business {FFFF00}\"%s\"{FF0000} is being evicted", ABusinessData[BusID][BusinessName]);
					SendClientMessage(pid, 0xFFFFFFFF, Msg);

					// Also remove the BusID from his list of businesses
					for (new BusSlot; BusSlot < MAX_BUSINESSPERPLAYER; BusSlot++)
					    // Check if the business is stored in this business-slot
					    if (APlayerData[pid][Business][BusSlot] == BusID)
					        // If the business is stored in this slot, clear the slot
					        APlayerData[pid][Business][BusSlot] = 0;

					// Save the player's account again
					PlayerFile_Save(pid);

					// Stop this For-loop, as the owner was already found and informed
					break;
				}
		    }
		}

		// Check if the player was not online
		if (PlayerOnline == false)
			// Remove the house from the player's account (open the account, remove the data and re-save it)
			PlayerFile_RemoveProperty(ABusinessData[BusID][Owner], 0, BusID);
	}

	// Clear ownership of the business
	ABusinessData[BusID][Owned] = false;
	ABusinessData[BusID][Owner] = 0;

	// Update the entrance of the business
	Business_UpdateEntrance(BusID);

	// Save the businessfile
	BusinessFile_Save(BusID);
}



// This function loads the playerfile for the given player, removes the lines that contain the HouseID or BusinessID and resaves the file
PlayerFile_RemoveProperty(Name[], HouseID, BusID)
{
	// Setup local variables
	new file[100], File:PFile, LineFromFile[100], Index, SearchString[100];

	// Construct the complete filename for this player's account
	format(file, sizeof(file), PlayerFile, Name);

	// Check if the player's datafile exists
	if (fexist(file))
	{
		// First clear the array before using it to make sure it's empty
		for (Index = 0; Index < 100; Index++)
            FileContent[Index][0] = 0;

		// Open the playerfile for reading
		PFile = fopen(file, io_read);

		// Read up to 100 lines from the file (no player-account should have more than this)
		for (Index = 0; Index < 100; Index++)
		{
			// Read a line from the file
			fread(PFile, LineFromFile);
			// Strip any newline characters from the LineFromFile
			StripNewLine(LineFromFile);

			// Check if this line holds data
			if (strlen(LineFromFile) > 0)
				// Store this line into the array
				format(FileContent[Index], 100, LineFromFile);
			else // If the read line doesn't contain any more data (empty string), the end of the file has been reached
			    break;
		}

        // Close the file
		fclose(PFile);



		// Now the file has been read and stored into the array, now scan the array to search for the matching HouseID and/or BusinessID

		// Loop through the entire array
		for (Index = 0; Index < 100; Index++)
		{
			// Build the string to search for the HouseID
			format(SearchString, 100, "House %i", HouseID);
			// Check if this line holds the string we're looking for
			if (strcmp(FileContent[Index], SearchString, false) == 0)
			    // Clear the array-index
			    FileContent[Index][0] = 0;

			// Build the string to search for the BusinessID
			format(SearchString, 100, "Business %i", BusID);
			// Check if this line holds the string we're looking for
			if (strcmp(FileContent[Index], SearchString, false) == 0)
			    // Clear the array-index
			    FileContent[Index][0] = 0;
		}


		// Now all matching HouseID's and BusinessID's should be removed from the account, now re-save the playerfile

        // Open the playerfile for writing
		PFile = fopen(file, io_write);

		// Loop through the entire array
		for (Index = 0; Index < 100; Index++)
		{
			// Check if there is data in this array-slot
			if (FileContent[Index][0] != 0)
			{
			    // Construct the line for saving
				format(LineFromFile, 100, "%s\r\n", FileContent[Index]);
		        // And save it to the file
				fwrite(PFile, LineFromFile);
			}
		}

        // Close the file
		fclose(PFile);
	}
}
Tenho gm caminhoneiro tambem, e esse comando tem no meu gm ^^
Reply
#4

@EDIT Cara deu 4 erros aqui no cуdigo que tu me mandou.....

pawn Код:
C:\DOCUME~1\ADMINI~1\Desktop\BRASIL~2\pawno\include\PPC_Common.inc(490) : error 017: undefined symbol "FileContent"
C:\DOCUME~1\ADMINI~1\Desktop\BRASIL~2\pawno\include\PPC_Common.inc(490) : warning 217: loose indentation
C:\DOCUME~1\ADMINI~1\Desktop\BRASIL~2\pawno\include\PPC_Common.inc(490) : warning 215: expression has no effect
C:\DOCUME~1\ADMINI~1\Desktop\BRASIL~2\pawno\include\PPC_Common.inc(490) : error 001: expected token: ";", but found "]"
C:\DOCUME~1\ADMINI~1\Desktop\BRASIL~2\pawno\include\PPC_Common.inc(490) : error 029: invalid expression, assumed zero
C:\DOCUME~1\ADMINI~1\Desktop\BRASIL~2\pawno\include\PPC_Common.inc(490) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
Linha 490>>>>>>> FileContent[Index][0] = 0;
Reply
#5

so adicionar no final dela ..

@EDIT

Adicione isto no TOPO do seu gamemode .

Код:
new FileContent[100][100];
Reply
#6

Quote:
Originally Posted by Nill.Oliveira
Посмотреть сообщение
so adicionar no final dela ..

@EDIT

Adicione isto no TOPO do seu gamemode .

Код:
new FileContent[100][100];
Certнcimo amigo muito obrigado, cara uma perguntinha jб que tu conhece o game mode.... Como desbuga o convoy do cement truck e aquele velocнmetro horrivel '-'? kkkk poderia me ajudar nisso?
Reply
#7

Explique-se melhor no oque estб bugado ?
Reply
#8

Quote:
Originally Posted by Nill.Oliveira
Посмотреть сообщение
Explique-se melhor no oque estб bugado ?
No convoy do cement truck somente o lнder pode usar cement truck os outros players precisam estar usando um DFT-30 ou Flatbed e o velocнmetro some sozinho toda hora, isso й, quando aparece...
Reply
#9

Bom vei . O velocimetro teria que construir denovo.
e sobre esse bug do convoy atй posso te ajudar, so nao agora qe eu to sem tempo nesses dias ^^ .
Mas adicione o Msn qe eu posso te ajudar qualquer hora nill_p14@hotmail.com

Lembre-se se eu te ajudei me ajude tambem com REP.
Reply
#10

Quote:
Originally Posted by Nill.Oliveira
Посмотреть сообщение
Bom vei . O velocimetro teria que construir denovo.
e sobre esse bug do convoy atй posso te ajudar, so nao agora qe eu to sem tempo nesses dias ^^ .
Mas adicione o Msn qe eu posso te ajudar qualquer hora nill_p14@hotmail.com

Lembre-se se eu te ajudei me ajude tambem com REP.
CARA VO TER DAR +REP E UM BEIJO PODE SER? , coisinha, teria como postar a tua include PPC_Convoys e a include PPC_Speedometer?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)