Check if a string is same as other string
#1

I would like to make a mask system similar to LSRP, but it is almost done, the only thing that left is to make let players input the ID of the mask instead of a player name or ID in commands without requiring the ID, this is what I got so far. This function will be used in commands to check if the Mask ID is active and it will return the player ID instead.

pawn Код:
IsMasked(target)
{
    new player, MaskName[64];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsMaskOn{i})
            {
        format(MaskName, sizeof(MaskName), "%d_%d", GetMaskLargeID(i), GetMaskSmallID(i));
                if(strcmp(MaskName, target)) // Error here, no idea what to do to check if a string is the same with another.
        {
                    player = i;
                }
        }
    }
    }
    return player;
}
Reply
#2

You can only compare strings with strings.

Код:
IsMasked(target[])
{
    new player, MaskName[64];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsMaskOn{i})
            {
                format(MaskName, sizeof(MaskName), "%d_%d", GetMaskLargeID(i), GetMaskSmallID(i));
                if(!strcmp(MaskName, target)) // Error here, no idea what to do to check if a string is the same with another.
                {
                    player = i;
                }
            }
        }
    }
    return player;
}
Reply
#3

Aw mate, thanks a lot.

Edit 2:
How am I supposed to use the function now, can I have an example with /pay [player] [amount]
Reply
#4

Bumb.
Reply
#5

Код:
CMD:givecash(playerid, params[])
{
    new target, amount;
    new Float:x, Float:y, Float:z;
    if(sscanf(params, "ui", target, amount)) return SendClientMessage(playerid, YOUR_COLOR, "USAGE: /givecash (name/id) (amount)");
    if(amount <= 0) return SendClientMessage(playerid,YOUR_COLOR,"You have to give cash atleast $1.");
    if(amount > GetPlayerMoney(playerid)) return SendClientMessage(playerid,YOUR_COLOR,"You dont have that much cash in hand");
    if(target == playerid) return SendClientMessage(playerid, YOUR_COLOR, "You can't give cash to yourself.");
    if(!IsPlayerConnected(target)) return SendClientMessage(playerid, YOUR_COLOR, "Player is not connected.");
    GetPlayerPos(target, x, y, z);
    if(!IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z)) return SendClientMessage(playerid, YOUR_COLOR, "Player is not close to you");

    new string[256], name[MAX_PLAYER_NAME], TargetName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerName(target, TargetName, sizeof(name));
    format(file,sizeof(file),PlayerFile,name);

	GivePlayerMoney(playerid, (0 - amount));
    GivePlayerMoney(target, amount);

    format(string,sizeof(string),"You have successfully given $%d to %s(%d).",amount,TargetName,target);
    SendClientMessage(playerid,YOUR_COLOR,string);

    format(string,sizeof(string),"%s(%d) has given you $%d.",name,playerid,amount);
    SendClientMessage(target,YOUR_COLOR,string);
}
Reply
#6

Quote:
Originally Posted by Sc0pion
Посмотреть сообщение
Код:
CMD:givecash(playerid, params[])
{
    new target, amount;
    new Float:x, Float:y, Float:z;
    if(sscanf(params, "ui", target, amount)) return SendClientMessage(playerid, YOUR_COLOR, "USAGE: /givecash (name/id) (amount)");
    if(amount <= 0) return SendClientMessage(playerid,YOUR_COLOR,"You have to give cash atleast $1.");
    if(amount > GetPlayerMoney(playerid)) return SendClientMessage(playerid,YOUR_COLOR,"You dont have that much cash in hand");
    if(target == playerid) return SendClientMessage(playerid, YOUR_COLOR, "You can't give cash to yourself.");
    if(!IsPlayerConnected(target)) return SendClientMessage(playerid, YOUR_COLOR, "Player is not connected.");
    GetPlayerPos(target, x, y, z);
    if(!IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z)) return SendClientMessage(playerid, YOUR_COLOR, "Player is not close to you");

    new string[256], name[MAX_PLAYER_NAME], TargetName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerName(target, TargetName, sizeof(name));
    format(file,sizeof(file),PlayerFile,name);

	GivePlayerMoney(playerid, (0 - amount));
    GivePlayerMoney(target, amount);

    format(string,sizeof(string),"You have successfully given $%d to %s(%d).",amount,TargetName,target);
    SendClientMessage(playerid,YOUR_COLOR,string);

    format(string,sizeof(string),"%s(%d) has given you $%d.",name,playerid,amount);
    SendClientMessage(target,YOUR_COLOR,string);
}
So I don't have to include the IsMasked on every command, right?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)