function doesn't effect
#1

PHP код:
CMD:scorefall(playeridparams[])
{
if(
Dead[playerid] == 1) return SendClientMessage(playeridCOLOR_RED"[INFO] You can't use commands while being dead!");
new 
value;
if(
PlayerInfo[playerid][pAdmin] <= 2) return SendClientMessage(playeridCOLOR_RED"ERROR: Insufficient Permissions!");
if(
sscanf(params"d"value)) return SendClientMessage(playeridCOLOR_LIGHTGREEN"Usage: /Scorefall [Amount]");
if(
value <= 0) return SendClientMessage(playeridCOLOR_RED"Invalid Amount!");
for(new 
i=0i<MAX_PLAYERSi++)
{
if(
IsPlayerConnected(i))
{
new 
name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
new 
string[128];
format(string,sizeof(string),"Admin %s has given all players %d Score.",namevalue);
SendClientMessageToAll(COLOR_YELLOW,string);
SetPlayerScore(iGetPlayerScore(i) + value);
new 
string2[128];
format(string2,sizeof(string2),"~h~scoref all~n~~h~+%d score",value);
GameTextForAll(string2,3000,3);
return 
1;
}
}
return 
0;

The command I've made is making a gametextforall and it does send the string but none of the players is getting the score.

If someone could fix the code I'll be thankful

""FIXED"" thanks for all
Reply
#2

Remove that "return 1;" after the GameTextForAll
Reply
#3

PHP код:
CMD:scorefall(playeridparams[]) 

    if(
Dead[playerid] == 1) return SendClientMessage(playeridCOLOR_RED"[INFO] You can't use commands while being dead!"); 
    new 
value
    if(
PlayerInfo[playerid][pAdmin] <= 2) return SendClientMessage(playeridCOLOR_RED"ERROR: Insufficient Permissions!"); 
    if(
sscanf(params"d"value)) return SendClientMessage(playeridCOLOR_LIGHTGREEN"Usage: /Scorefall [Amount]"); 
    if(
value <= 0) return SendClientMessage(playeridCOLOR_RED"Invalid Amount!"); 
    for(new 
i=0i<MAX_PLAYERSi++) 
    { 
        if(
IsPlayerConnected(i)) 
        { 
            new 
name[MAX_PLAYER_NAME]; 
            
GetPlayerName(playerid,name,sizeof(name)); 
            new 
string[128]; 
            
format(string,sizeof(string),"Admin %s has given all players %d Score.",namevalue); 
            
SendClientMessageToAll(COLOR_YELLOW,string);
            new 
=  GetPlayerScore(i);    
            
SetPlayerScore(is+value); 
            
format(string,sizeof(string),"~h~score all~n~~h~+%d score",value); 
            
GameTextForAll(string,3000,3); 
        } 
    } 
    return 
1

Reply
#4

Quote:
Originally Posted by Macronix
Посмотреть сообщение
Remove that "return 1;" after the GameTextForAll
It does fix the old problem, but then the message multiple itself and 2 same messages send to all.

Like that:
"Admin %s has given all players %d Score."
"Admin %s has given all players %d Score."

I knew already how to fix the old problem, but when I remove the return 1; from there it multiple the msg.
Reply
#5

Damn... just put the message out of the loop
Reply
#6

Quote:
Originally Posted by iLearner
Посмотреть сообщение
Damn... just put the message out of the loop
How to do that?

I need the "value" to be inside the loop, and all the other checkers and correct usages isn't a good place to put it..
Reply
#7

There you go:

Код:
CMD:scorefall(playerid, params[])
{
	if(Dead[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "[INFO] You can't use commands while being dead!");
	
	new value, name[MAX_PLAYER_NAME], string[128], string2[128];
	
	if(PlayerInfo[playerid][pAdmin] <= 2) return SendClientMessage(playerid, COLOR_RED, "ERROR: Insufficient Permissions!");
	if(sscanf(params, "d", value)) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "Usage: /Scorefall [Amount]");
	if(value <= 0) return SendClientMessage(playerid, COLOR_RED, "Invalid Amount!");

	for(new i=0; i<MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			SetPlayerScore(i, GetPlayerScore(i) + value);
		}
	}
	
	GetPlayerName(playerid,name,sizeof(name));
	format(string,sizeof(string),"Admin %s has given all players %d Score.",name, value);
	SendClientMessageToAll(COLOR_YELLOW,string);
	
	format(string2,sizeof(string2),"~h~scoref all~n~~h~+%d score",value);
	GameTextForAll(string2,3000,3);
	
	return 0;
}
Reply
#8

Quote:
Originally Posted by Macronix
Посмотреть сообщение
There you go:

Код:
CMD:scorefall(playerid, params[])
{
	if(Dead[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "[INFO] You can't use commands while being dead!");
	
	new value, name[MAX_PLAYER_NAME], string[128], string2[128];
	
	if(PlayerInfo[playerid][pAdmin] <= 2) return SendClientMessage(playerid, COLOR_RED, "ERROR: Insufficient Permissions!");
	if(sscanf(params, "d", value)) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "Usage: /Scorefall [Amount]");
	if(value <= 0) return SendClientMessage(playerid, COLOR_RED, "Invalid Amount!");

	for(new i=0; i<MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			SetPlayerScore(i, GetPlayerScore(i) + value);
		}
	}
	
	GetPlayerName(playerid,name,sizeof(name));
	format(string,sizeof(string),"Admin %s has given all players %d Score.",name, value);
	SendClientMessageToAll(COLOR_YELLOW,string);
	
	format(string2,sizeof(string2),"~h~scoref all~n~~h~+%d score",value);
	GameTextForAll(string2,3000,3);
	
	return 0;
}
Thanks a lot! +repped
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)