[+REP] "for" function problem
#1

Hello, I've scripted a command to buy a house, I made it currently to send you a message contains the id of the house checkpoint that you are in, but if I use the command while not in a checkpoint, it spams sending me message"word_system"0.... tons of times.

Код:
CMD:h(playerid, params[])
{
	new selection[10];
	if(sscanf(params, "s[20]", selection)) return SendUsageMSG(playerid, "/h [BUY/SELL/CONFIG]");

	if(!strcmp(selection, "buy", true))
	{
	    for(new i = 0; i < MAX_HOUSES; i++)
	    {
	        if(IsPlayerInDynamicCP(playerid, hInfo[i][EntranceCP]))
	        {
	            if(hInfo[i][hOwned] == 0)
	            {
					new string[128];
					format(string, sizeof(string), ""WORD_SYSTEM"%d", hInfo[i][hID]);
					SCM(playerid, COLOR_WHITE, string);
					SetHouseOwner(i, PlayerName(playerid));
				}
			}
		}
	}
	return 1;
}
EDITED
Reply
#2

It spams because checkpoints are having internal refresh/update in the game. That's why your chat box is getting loads of the same messages.
Reply
#3

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
It spams because checkpoints are having internal refresh/update in the game. That's why your chat box is getting loads of the same messages.
Edited the thread, and explain more.
Reply
#4

BUMP
Reply
#5

PHP код:
CMD:h(playerid,params[])
{
    new 
selection[10],string[145];
    if(
sscanf(params,"s[10]",selection))return SendUsageMSG(playerid,"/h [BUY/SELL/CONFIG]");
    if(!
strcmp(selection,"buy",true))
    {
        for(new 
i;i<MAX_HOUSES;i++)
        {
            if(
IsPlayerInDynamicCP(playerid,hInfo[i][EntranceCP]))
            {
                if(
hInfo[i][hOwned9 == 0)
                {
                    
format(string,sizeof(string),""WORD_SYSTEM"%d",hInfo[i][hID]);
                    
SCM(playerid,COLOR_WHITE,string);
                    
SetHouseOwner(i,PlayerName(playerid));
                    break;
                }
            }
        }
    }
    return 
1;

Reply
#6

Quote:
Originally Posted by Mencent
Посмотреть сообщение
PHP код:
CMD:h(playerid,params[])
{
    new 
selection[10],string[145];
    if(
sscanf(params,"s[10]",selection))return SendUsageMSG(playerid,"/h [BUY/SELL/CONFIG]");
    if(!
strcmp(selection,"buy",true))
    {
        for(new 
i;i<MAX_HOUSES;i++)
        {
            if(
IsPlayerInDynamicCP(playerid,hInfo[i][EntranceCP]))
            {
                if(
hInfo[i][hOwned9 == 0)
                {
                    
format(string,sizeof(string),""WORD_SYSTEM"%d",hInfo[i][hID]);
                    
SCM(playerid,COLOR_WHITE,string);
                    
SetHouseOwner(i,PlayerName(playerid));
                    break;
                }
            }
        }
    }
    return 
1;

Thank you! +REP'd
Reply
#7

There is still another problem, when I /h buy while not in any checkpoint, it says: 0, as scripted, it has to say: you must be in a house checkpoint..
Reply
#8

Код:
CMD:h(playerid,params[]) 
{ 
    new selection[10],string[145]; 
    if(sscanf(params,"s[10]",selection))return SendUsageMSG(playerid,"/h [BUY/SELL/CONFIG]"); 
    if(!strcmp(selection,"buy",true)) 
    { 
        for(new i;i<MAX_HOUSES;i++) 
        { 
            if(IsPlayerInDynamicCP(playerid,hInfo[i][EntranceCP])) 
            { 
                if(hInfo[i][hOwned9 == 0) 
                { 
                    format(string,sizeof(string),""WORD_SYSTEM"%d",hInfo[i][hID]); 
                    SCM(playerid,COLOR_WHITE,string); 
                    SetHouseOwner(i,PlayerName(playerid)); 
                    break; 
                } 
            }
            else
            {
                  SCM(playerid, COLOR_WHITE, "ERROR: You need to be in a house checkpoint!");
            }
        }
    } 
    return 1; 
}
Reply
#9

Quote:
Originally Posted by -CaRRoT
Посмотреть сообщение
Код:
CMD:h(playerid,params[]) 
{ 
    new selection[10],string[145]; 
    if(sscanf(params,"s[10]",selection))return SendUsageMSG(playerid,"/h [BUY/SELL/CONFIG]"); 
    if(!strcmp(selection,"buy",true)) 
    { 
        for(new i;i<MAX_HOUSES;i++) 
        { 
            if(IsPlayerInDynamicCP(playerid,hInfo[i][EntranceCP])) 
            { 
                if(hInfo[i][hOwned9 == 0) 
                { 
                    format(string,sizeof(string),""WORD_SYSTEM"%d",hInfo[i][hID]); 
                    SCM(playerid,COLOR_WHITE,string); 
                    SetHouseOwner(i,PlayerName(playerid)); 
                    break; 
                } 
            }
            else
            {
                  SCM(playerid, COLOR_WHITE, "ERROR: You need to be in a house checkpoint!");
            }
        }
    } 
    return 1; 
}
Thank you! <3 rep
Reply
#10

-CaRRoT, I've used your script, but when I do /h buy while not in a house checkpoints, it spams me "You must be in a house cp..." 5 or 6 times, then it says: 0
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)