minlevel
#1

i have this cmd /invite if i do not have space in my faction works it gives me the message like "your factions is full" and if i have space i can invite it works but i have just a problem

minlevel is not working i mean he is level 2 and i have at my faction minlevel 5 and i still can invite him
what is wrong with this cmd ?

Код HTML:
CMD:invite(playerid, params[])
{
	new 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>");
    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(FactionMembers(PlayerInfo[playerid][pLeader]) >= FactionInfo[PlayerInfo[playerid][pLeader]][fSlots]) return SendClientMessage(playerid, COLOR_ERROR, "Your faction is full.");
    if(FactionLevelMembers(PlayerInfo[playerid][pLeader]) >= FactionInfo[PlayerInfo[playerid][pLeader]][fMinLevel]) return SendClientMessage(playerid, COLOR_ERROR, "His level is to low.");
    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;
}
and also have this both first is for space in faction

Код HTML:
function FactionMembers(faction)
{
    gQuery[0] = (EOS);
	mysql_format(handle, gQuery, sizeof(gQuery), "SELECT `ID` FROM `players` WHERE `Member` = %d", faction);
 	new Cache:result = mysql_query(handle, gQuery);
	new number = cache_num_rows();
	cache_delete(result);
	return number;
}
and this for minlevel

Код HTML:
function FactionLevelMembers(faction)
{
    gQuery[0] = (EOS);
	mysql_format(handle, gQuery, sizeof(gQuery), "SELECT `ID` FROM `factions` WHERE `MinLevel` = %d", faction);
 	new Cache:result = mysql_query(handle, gQuery);
	new number = cache_num_rows();
	cache_delete(result);
	return number;
}
what could be wrong ?
Reply
#2

I have fixed some errors on the command but not the issue itself because there are some parts which is very confusing.

PHP код:
CMD:invite(playeridparams[])
{
    new 
giveplayeridgiveplayerid;
    if(!
gLogged[playerid])
        return 
SendClientMessage(playeridCOLOR_ERROR"Tu nu esti logat si nu poti sa folosesti aceasta comanda!");
    if(!
PlayerInfo[playerid][pLeader])
        return 
SendClientMessage(playeridCOLOR_ERROR"You don't have leader.");
    if(
sscanf(params,"u"giveplayerid))
        return 
SendClientMessage(playeridCOLOR_SYN"Sintaxa:{FFFFFF} /invite <Player ID/Name>");
    if(
giveplayerid == playerid)
        return 
SendClientMessage(playeridCOLOR_ERROR"You cannot invite yourself.");
        
    if(
giveplayerid == INVALID_PLAYER_ID)
        return 
InvalidPlayer(playerid);
    if(
FactionMembers(PlayerInfo[playerid][pLeader]) >= FactionInfo[PlayerInfo[playerid][pLeader]][fSlots])
        return 
SendClientMessage(playeridCOLOR_ERROR"Your faction is full.");
        
    if(
FactionLevelMembers(PlayerInfo[playerid][pLeader]) >= FactionInfo[PlayerInfo[playerid][pLeader]][fMinLevel])
        return 
SendClientMessage(playeridCOLOR_ERROR"His level is to low.");
        
    if(
PlayerInfo[giveplayerid][pMember] + PlayerInfo[giveplayerid][pLeader] != || PlayerInfo[giveplayerid][pFPunish] > 0)
        return 
SendClientMessage(playeridCOLOR_ERROR"Player is already in a faction/has faction punish.");
    
// I do not understand what GetPlayers do, Can you explain what does GetPlayers do?
    
if(GetPlayers(splayer) == 1000) return ToManyResults(playerid);
    else if(
GetPlayers(splayer) == 1001) return ShowResults(playeridsplayer);
       
// I do not understand what GetPlayers do, Can you explain what does GetPlayers do?
    
InviteOffer[giveplayerid] = 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;

*******************

First of all, You could just use "u" instead of "s", sscanf has a built-in playerid/name specifier so whenever you type either of them the result would be the same (playerid 0 - HarleyQuinn, /kick Harley or /kick 0 = Kicks HarleyQuinn)

As for this part, I do not understand this part at all.

PHP код:
// I do not understand what GetPlayers do, Can you explain what does GetPlayers do?
if(GetPlayers(splayer) == 1000) return ToManyResults(playerid);
else if(
GetPlayers(splayer) == 1001) return ShowResults(playeridsplayer);
// I do not understand what GetPlayers do, Can you explain what does GetPlayers do? 
You aren't storing anything on the fuction FactionLevelMembers, you even misused the execution of the query instead of selecting the MinLevel, you have selected the ID and instead of specifying the location of the faction which is ID, you have placed the MinLevel instead. It should have been like this instead;

PHP код:
SELECT `MinLevelFROM `factionsWHERE `ID` = %
I don't know how MySQL works so i don't know how to retrieve the values, Wait for someone to reply about it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)