/asellhouseall command
#1

Код:
if(strcmp(cmd, "/asellhouseall", true) == 0)
{
	if(IsPlayerConnected(playerid))
 	{
		GetPlayerName(playerid, playername, sizeof(playername));
		if (PlayerInfo[playerid][pAdmin] >= 5000)
		{
		    for(new house = 0; house <= 700; house++)
		    {
				HouseInfo[house][hHel] = 0;
				HouseInfo[house][hArm] = 0;
				HouseInfo[house][hHealthx] = 0;
				HouseInfo[house][hHealthy] = 0;
				HouseInfo[house][hHealthz] = 0;
				HouseInfo[house][hArmourx] = 0;
				HouseInfo[house][hArmoury] = 0;
				HouseInfo[house][hArmourz] = 0;
				HouseInfo[house][hLock] = 1;
				HouseInfo[house][hOwned] = 0;
				HouseInfo[house][hVec] = 418;
				HouseInfo[house][hVcol1] = -1;
				HouseInfo[house][hVcol2] = -1;
				strmid(HouseInfo[house][hOwner], "The State", 0, strlen("The State"), 255);
				PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
				format(string, sizeof(string), "~w~You have sold all property", HouseInfo[house][hValue]);
				GameTextForPlayer(playerid, string, 10000, 3);
				OnPropUpdate();
				return 1;
			}
		}
		else
		{
			SendClientMessage(playerid, COLOR_WHITE, "You are not an admin.");
		}
	}
	return 1;
}
Its dont sell all the houses and its say "You have sold all property" ...
I want from that it will sell id 1-700
the defualt command is :
Код:
	if(strcmp(cmd, "/asellhouse", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
		{
			GetPlayerName(playerid, playername, sizeof(playername));
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /asellhouse [houseid]");
				return 1;
			}
			new house = strval(tmp);
			if (PlayerInfo[playerid][pAdmin] >= 1338)
			{
				HouseInfo[house][hHel] = 0;
				HouseInfo[house][hArm] = 0;
				HouseInfo[house][hHealthx] = 0;
				HouseInfo[house][hHealthy] = 0;
				HouseInfo[house][hHealthz] = 0;
				HouseInfo[house][hArmourx] = 0;
				HouseInfo[house][hArmoury] = 0;
				HouseInfo[house][hArmourz] = 0;
				HouseInfo[house][hLock] = 1;
				HouseInfo[house][hOwned] = 0;
				HouseInfo[house][hVec] = 418;
				HouseInfo[house][hVcol1] = -1;
				HouseInfo[house][hVcol2] = -1;
				strmid(HouseInfo[house][hOwner], "The State", 0, strlen("The State"), 255);
				PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
				format(string, sizeof(string), "~w~You have sold this property", HouseInfo[house][hValue]);
				GameTextForPlayer(playerid, string, 10000, 3);
				OnPropUpdate();
    			format(string, sizeof(string), ">>Admin %s Sold House ID %d / %d", sendername, HouseInfo[house], house);
                BuyHouseLog(string);
				return 1;
			}
			else
			{
				SendClientMessage(playerid, COLOR_WHITE, "You are not an admin.");
			}
		}
		return 1;
	}
Reply
#2

Quote:
Originally Posted by hanm13
Посмотреть сообщение
Код:
if(strcmp(cmd, "/asellhouseall", true) == 0)
{
	if(IsPlayerConnected(playerid))
 	{
		GetPlayerName(playerid, playername, sizeof(playername));
		if (PlayerInfo[playerid][pAdmin] >= 5000)
		{
		    for(new house = 0; house <= 700; house++)
		    {
				HouseInfo[house][hHel] = 0;
				HouseInfo[house][hArm] = 0;
				HouseInfo[house][hHealthx] = 0;
				HouseInfo[house][hHealthy] = 0;
				HouseInfo[house][hHealthz] = 0;
				HouseInfo[house][hArmourx] = 0;
				HouseInfo[house][hArmoury] = 0;
				HouseInfo[house][hArmourz] = 0;
				HouseInfo[house][hLock] = 1;
				HouseInfo[house][hOwned] = 0;
				HouseInfo[house][hVec] = 418;
				HouseInfo[house][hVcol1] = -1;
				HouseInfo[house][hVcol2] = -1;
				strmid(HouseInfo[house][hOwner], "The State", 0, strlen("The State"), 255);
				PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
				format(string, sizeof(string), "~w~You have sold all property", HouseInfo[house][hValue]);
				GameTextForPlayer(playerid, string, 10000, 3);
				OnPropUpdate();
				return 1;
			}
		}
		else
		{
			SendClientMessage(playerid, COLOR_WHITE, "You are not an admin.");
		}
	}
	return 1;
}
You put the "return 1;" in that for. So the only thing that command wil do is to sell the house=0, then finishes its execution.
pawn Код:
if(strcmp(cmd, "/asellhouseall", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        GetPlayerName(playerid, playername, sizeof(playername));
        if (PlayerInfo[playerid][pAdmin] >= 5000)
        {
            for(new house = 0; house <= 700; house++)
            {
                HouseInfo[house][hHel] = 0;
                HouseInfo[house][hArm] = 0;
                HouseInfo[house][hHealthx] = 0;
                HouseInfo[house][hHealthy] = 0;
                HouseInfo[house][hHealthz] = 0;
                HouseInfo[house][hArmourx] = 0;
                HouseInfo[house][hArmoury] = 0;
                HouseInfo[house][hArmourz] = 0;
                HouseInfo[house][hLock] = 1;
                HouseInfo[house][hOwned] = 0;
                HouseInfo[house][hVec] = 418;
                HouseInfo[house][hVcol1] = -1;
                HouseInfo[house][hVcol2] = -1;
                strmid(HouseInfo[house][hOwner], "The State", 0, strlen("The State"), 255);
                PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                OnPropUpdate();
                //return 1;
            }
            GameTextForPlayer(playerid, "~w~You have sold all properties.", 10000, 3);
        }
        else
        {
            SendClientMessage(playerid, COLOR_WHITE, "You are not an admin.");
        }
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by Koala818
Посмотреть сообщение
You put the "return 1;" in that for. So the only thing that command wil do is to sell the house=0, then finishes its execution.
pawn Код:
if(strcmp(cmd, "/asellhouseall", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        GetPlayerName(playerid, playername, sizeof(playername));
        if (PlayerInfo[playerid][pAdmin] >= 5000)
        {
            for(new house = 0; house <= 700; house++)
            {
                HouseInfo[house][hHel] = 0;
                HouseInfo[house][hArm] = 0;
                HouseInfo[house][hHealthx] = 0;
                HouseInfo[house][hHealthy] = 0;
                HouseInfo[house][hHealthz] = 0;
                HouseInfo[house][hArmourx] = 0;
                HouseInfo[house][hArmoury] = 0;
                HouseInfo[house][hArmourz] = 0;
                HouseInfo[house][hLock] = 1;
                HouseInfo[house][hOwned] = 0;
                HouseInfo[house][hVec] = 418;
                HouseInfo[house][hVcol1] = -1;
                HouseInfo[house][hVcol2] = -1;
                strmid(HouseInfo[house][hOwner], "The State", 0, strlen("The State"), 255);
                PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                OnPropUpdate();
                //return 1;
            }
            GameTextForPlayer(playerid, "~w~You have sold all properties.", 10000, 3);
        }
        else
        {
            SendClientMessage(playerid, COLOR_WHITE, "You are not an admin.");
        }
    }
    return 1;
}
Thanks, but I hear the sound 700 times...
Reply
#4

bump
Reply
#5

You have made a loop for all of the houses,and the houses's amount i mean the maximum as it's defined in your script is 700,so it plays sound 700 time because you have put the playing sound code under the loop which will make it run 700 times,use this:
pawn Код:
if(strcmp(cmd, "/asellhouseall", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        GetPlayerName(playerid, playername, sizeof(playername));
        if (PlayerInfo[playerid][pAdmin] >= 5000)
        {
            for(new house = 0; house <= 700; house++)
            {
                HouseInfo[house][hHel] = 0;
                HouseInfo[house][hArm] = 0;
                HouseInfo[house][hHealthx] = 0;
                HouseInfo[house][hHealthy] = 0;
                HouseInfo[house][hHealthz] = 0;
                HouseInfo[house][hArmourx] = 0;
                HouseInfo[house][hArmoury] = 0;
                HouseInfo[house][hArmourz] = 0;
                HouseInfo[house][hLock] = 1;
                HouseInfo[house][hOwned] = 0;
                HouseInfo[house][hVec] = 418;
                HouseInfo[house][hVcol1] = -1;
                HouseInfo[house][hVcol2] = -1;
                strmid(HouseInfo[house][hOwner], "The State", 0, strlen("The State"), 255);
                OnPropUpdate();
                return 1;
            }
            GameTextForPlayer(playerid, "~w~You have sold all properties.", 10000, 3);
            PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
        }
        else
        {
            SendClientMessage(playerid, COLOR_WHITE, "You are not an admin.");
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)