Invite command
#1

hey guys i have a /invite command where if you have maxmembers setter by an admin like 5/5 you can't invite more but i have a problem i am alone i have 0/5 members and i can't invite it say's "you reached the maximum members"

Код HTML:
stock GetFactionMembers(fid)
{
	new
		Cache: Result,
		Get[2];
	format(gQuery, sizeof(gQuery), "SELECT `Member` FROM `players` WHERE `Member` = %d", fid);
    Result = mysql_query(handle, gQuery);
    cache_get_data(Get[0], Get[1], handle);
    cache_delete(Result);
	return Get[0];
}
and the /invite command

Код HTML:
CMD:invite(playerid, params[])
{
	new id, giveplayerid, splayer[25];
	if(gLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_ERROR, "Tu nu esti logat si nu poti sa folosesti aceasta comanda!");
	if(PlayerInfo[playerid][pLeader] == 0) return SendClientMessage(playerid, COLOR_ERROR, "You don't have leader.");
	if(sscanf(params,"s[25]", splayer)) return SendClientMessage(playerid, COLOR_SYN, "Sintaxa:{FFFFFF} /invite <Player ID/Name>");
	{
	    new membrii = GetFactionMembers(PlayerInfo[playerid][pMember]);
   		if(membrii >= DynamicFactions[PlayerInfo[playerid][pMember]][fMaxMembers]) return SendClientMessage(playerid, COLOR_LIGHTRED, "You have reached maximum faction members.");
		if(PlayerInfo[id][pLevel] < DynamicFactions[PlayerInfo[playerid][pMember]][fMinLevel])
		{
			format(gString,sizeof(gString),"Pentru a invita un membru in aceasta factiune acesta trebuie sa aiba minim level %d.",DynamicFactions[PlayerInfo[playerid][pMember]][fMinLevel]);
			SendClientMessage(playerid, COLOR_LIGHTRED, gString);
			return 1;
		}
	    if(GetPlayers(splayer) == INVALID_PLAYER_ID) return InvalidPlayer(playerid);
		else if(GetPlayers(splayer) == 1000) return ToManyResults(playerid);
		else if(GetPlayers(splayer) == 1001) return ShowResults(playerid, splayer);
		else giveplayerid = GetPlayers(splayer);
		if(giveplayerid == playerid) return SendClientMessage(playerid, COLOR_ERROR, "You cannot invite yourself.");
		if(PlayerInfo[giveplayerid][pMember] + PlayerInfo[giveplayerid][pLeader] != 0 || PlayerInfo[giveplayerid][pFPunish] > 0) return SendClientMessage(playerid, COLOR_ERROR, "Player is already in a faction/has faction punish.");

		InviteOffer[giveplayerid][playerid] = PlayerInfo[playerid][pLeader];

		format(gString, sizeof(gString), "L-ai invitat pe %s sa se alature factiunii tale.",GetName(giveplayerid));
		SendClientMessage(playerid, COLOR_SYN2, gString);
		format(gString, sizeof(gString), "Liderul %s te-a invitat sa te alaturi %s, scrie (/accept invite %d) ca sa accepti.",GetName(playerid),FactionName[PlayerInfo[playerid][pLeader]],playerid);
		SendClientMessage(giveplayerid, COLOR_SYN2, gString);
	}
	return 1;
}
what is wrong :-s ?
Reply
#2

You have an useless brackets
Код:
CMD:invite(playerid, params[])
{
	new id, giveplayerid, splayer[25];
	if(gLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_ERROR, "Tu nu esti logat si nu poti sa folosesti aceasta comanda!");
	if(PlayerInfo[playerid][pLeader] == 0) return SendClientMessage(playerid, COLOR_ERROR, "You don't have leader.");
	if(sscanf(params,"s[25]", splayer)) return SendClientMessage(playerid, COLOR_SYN, "Sintaxa:{FFFFFF} /invite <Player ID/Name>");
	{//or add "else {"
	    new membrii = GetFactionMembers(PlayerInfo[playerid][pMember]);
   		if(membrii >= DynamicFactions[PlayerInfo[playerid][pMember]][fMaxMembers]) return SendClientMessage(playerid, COLOR_LIGHTRED, "You have reached maximum faction members.");
		if(PlayerInfo[id][pLevel] < DynamicFactions[PlayerInfo[playerid][pMember]][fMinLevel])
		{
			format(gString,sizeof(gString),"Pentru a invita un membru in aceasta factiune acesta trebuie sa aiba minim level %d.",DynamicFactions[PlayerInfo[playerid][pMember]][fMinLevel]);
			SendClientMessage(playerid, COLOR_LIGHTRED, gString);
			return 1;
		}
	    if(GetPlayers(splayer) == INVALID_PLAYER_ID) return InvalidPlayer(playerid);
		else if(GetPlayers(splayer) == 1000) return ToManyResults(playerid);
		else if(GetPlayers(splayer) == 1001) return ShowResults(playerid, splayer);
		else giveplayerid = GetPlayers(splayer);
		if(giveplayerid == playerid) return SendClientMessage(playerid, COLOR_ERROR, "You cannot invite yourself.");
		if(PlayerInfo[giveplayerid][pMember] + PlayerInfo[giveplayerid][pLeader] != 0 || PlayerInfo[giveplayerid][pFPunish] > 0) return SendClientMessage(playerid, COLOR_ERROR, "Player is already in a faction/has faction punish.");

		InviteOffer[giveplayerid][playerid] = PlayerInfo[playerid][pLeader];

		format(gString, sizeof(gString), "L-ai invitat pe %s sa se alature factiunii tale.",GetName(giveplayerid));
		SendClientMessage(playerid, COLOR_SYN2, gString);
		format(gString, sizeof(gString), "Liderul %s te-a invitat sa te alaturi %s, scrie (/accept invite %d) ca sa accepti.",GetName(playerid),FactionName[PlayerInfo[playerid][pLeader]],playerid);
		SendClientMessage(giveplayerid, COLOR_SYN2, gString);
	}
	return 1;
}
Reply
#3

done , but now i have 1/3 members and it say's "you reached the maximum members" and i have only 1 member from 3
Reply
#4

PHP код:
CMD:invite(playeridparams[])
{
    new 
idgiveplayeridsplayer[25];
    if(
gLogged[playerid] == 0) return SendClientMessage(playeridCOLOR_ERROR"Tu nu esti logat si nu poti sa folosesti aceasta comanda!");
    if(
PlayerInfo[playerid][pLeader] == 0) return SendClientMessage(playeridCOLOR_ERROR"You don't have leader.");
    if(
sscanf(params,"s[25]"splayer)) return SendClientMessage(playeridCOLOR_SYN"Sintaxa:{FFFFFF} /invite <Player ID/Name>");
        new 
membrii GetFactionMembers(PlayerInfo[playerid][pMember]);
         
printf("membrii = %d and fMaxMembers = %d"membriiDynamicFactions[PlayerInfo[playerid][pMember]][fMaxMembers]);
           if(
membrii >= DynamicFactions[PlayerInfo[playerid][pMember]][fMaxMembers]) return SendClientMessage(playeridCOLOR_LIGHTRED"You have reached maximum faction members.");
        if(
PlayerInfo[id][pLevel] < DynamicFactions[PlayerInfo[playerid][pMember]][fMinLevel])
        {
            
format(gString,sizeof(gString),"Pentru a invita un membru in aceasta factiune acesta trebuie sa aiba minim level %d.",DynamicFactions[PlayerInfo[playerid][pMember]][fMinLevel]);
            
SendClientMessage(playeridCOLOR_LIGHTREDgString);
            return 
1;
        }
        if(
GetPlayers(splayer) == INVALID_PLAYER_ID) return InvalidPlayer(playerid);
        else if(
GetPlayers(splayer) == 1000) return ToManyResults(playerid);
        else if(
GetPlayers(splayer) == 1001) return ShowResults(playeridsplayer);
        else 
giveplayerid GetPlayers(splayer);
        if(
giveplayerid == playerid) return SendClientMessage(playeridCOLOR_ERROR"You cannot invite yourself.");
        if(
PlayerInfo[giveplayerid][pMember] + PlayerInfo[giveplayerid][pLeader] != || PlayerInfo[giveplayerid][pFPunish] > 0) return SendClientMessage(playeridCOLOR_ERROR"Player is already in a faction/has faction punish.");
        
InviteOffer[giveplayerid][playerid] = PlayerInfo[playerid][pLeader];
        
format(gStringsizeof(gString), "L-ai invitat pe %s sa se alature factiunii tale.",GetName(giveplayerid));
        
SendClientMessage(playeridCOLOR_SYN2gString);
        
format(gStringsizeof(gString), "Liderul %s te-a invitat sa te alaturi %s, scrie (/accept invite %d) ca sa accepti.",GetName(playerid),FactionName[PlayerInfo[playerid][pLeader]],playerid);
        
SendClientMessage(giveplayeridCOLOR_SYN2gString);
    return 
1;

Use this command and tell me what prints on your log
Reply
#5

yea .. is the same that message with reached max members
Reply
#6

I know i changed nothing, just tell me what prints on the log
Reply
#7

this

Код HTML:
[18:55:57] membrii = 17 and fMaxMembers = 0
Reply
#8

This means
GetFactionMembers(PlayerInfo[playerid][pMember]); and DynamicFactions[PlayerInfo[playerid][pMember]][fMaxMembers]
Both not working fine, MaxMembers in this case returns 0, and Faction members is 17
Reply
#9

ok, thx
Reply
#10

If you only need a count of something then you should use the COUNT() aggregate function. This is much more efficient than getting the row count because only a single value is sent instead of the entire result set.
PHP код:
SELECT COUNT(*) FROM players WHERE Member = %
This value can then simply be retrieved with (assuming R40) cache_get_value_index_int().
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)