fexists doesn't work?
#1

pawn Код:
if(strfind(Player[i][Ref], "Nothing", false))
                    {
                        new Referral = Player[i][Ref];
                        format(string, sizeof(string), "Accounts/%s.ini", Player[i][Ref]);
                        if(fexist(string))
                        {
                            if (IsPlayerConnected(Referral))
                            {
                                Player[Referral][Refs]++;
                                Player[Referral][Money] += 10000;
                                Player[Referral][Pot] += 20;
                                Player[Referral][Cocaine] += 15;
                                Player[Referral][Materials] += 2000;
                                SendClientMessage(i, DEPARTMENT_CHAT, "Your referral is online and was rewarded, as you reached your fifth playing hour!.");
                                SendClientMessage(i, DEPARTMENT_CHAT, "Enjoy the server.");

                                SendClientMessage(Referral, DEPARTMENT_CHAT, "One of the players you brought to the server reached his fifth played hour!", GetName(i));
                                SendClientMessage(Referral, DEPARTMENT_CHAT, "You were given a reward! Thanks for your effort to improve the community!");
                                format(string, sizeof(string), "%s gained 5 playing hours - he was brought by %s.", Referral, i);
                                RefLog(string);
                            }
                            else
                            {
                                format(string, sizeof(string), "Accounts/%s.ini", Player[i][Ref]);
                                dini_IntSet(string, "PendingRef", 1);
                                SendClientMessage(Referral, DEPARTMENT_CHAT, "Your referral is not online but he'll be rewarded when he's online, for your fifth playing hour!", Player[i][Ref]);
                                SendClientMessage(Referral, DEPARTMENT_CHAT, "Enjoy the server.");
                                format(string, sizeof(string), "%s gained 5 playing hours - he was brought by %s but was not online!", Referral, i);
                                RefLog(string);
                            }
                        }
                        else
                        {
                        SendClientMessage(i, WHITE, "Your referral changed his name! Unable to reward him.");
                        }
                    }
Even if the account exists and is not online, it says that it's unable to reward him... how to solve this?
Reply
#2

You cannot use the command if the player is not online,
the only way is SQLite or MYSQL
Reply
#3

Quote:
Originally Posted by Romel
Посмотреть сообщение
You cannot use the command if the player is not online,
the only way is SQLite or MYSQL
In fact my script has several commands that work on players who are offline and these work properly.
Reply
#4

changed it to:

pawn Код:
if(strfind(Player[i][Ref], "Nothing", false))
                    {
                            new Referral = Player[i][Ref];
                           
                            if (IsPlayerConnected(Referral))
                            {
                                Player[Referral][Refs]++;
                                Player[Referral][Money] += 10000;
                                Player[Referral][Pot] += 20;
                                Player[Referral][Cocaine] += 15;
                                Player[Referral][Materials] += 2000;
                                SendClientMessage(i, DEPARTMENT_CHAT, "Your referral is online and was rewarded, as you reached your fifth playing hour!.");
                                SendClientMessage(i, DEPARTMENT_CHAT, "Enjoy the server.");

                                SendClientMessage(Referral, DEPARTMENT_CHAT, "One of the players you brought to the server reached his fifth played hour!", GetName(i));
                                SendClientMessage(Referral, DEPARTMENT_CHAT, "You were given a reward! Thanks for your effort to improve the community!");
                                format(string, sizeof(string), "%s gained 5 playing hours - he was brought by %s.", Referral, i);
                                RefLog(string);
                            }
                            else
                            {
                                format(string, sizeof(string), "Accounts/%s.ini", Player[i][Ref]);
                                dini_IntSet(string, "PendingRef", 1);
                                SendClientMessage(Referral, DEPARTMENT_CHAT, "Your referral is not online but he'll be rewarded when he's online, for your fifth playing hour!", Player[i][Ref]);
                                SendClientMessage(Referral, DEPARTMENT_CHAT, "Enjoy the server.");
                                format(string, sizeof(string), "%s gained 5 playing hours - he was brought by %s but was not online!", Referral, i);
                                RefLog(string);
                            }
                        }
Now it gives the player who gets the fifth playing hour the stuff, instead of the offline guy...
Reply
#5

You can use dini_Exists you know..

What's Player[i][Ref]?
Reply
#6

Ref is:
pawn Код:
command(referral, playerid, params[])
{
    new Name[128], string[128], string2[128], reffer[128];
   
    if(sscanf(params, "s", Name))
    {
        if(Player[playerid][PlayingHours] >= 0)
        {
            SendClientMessage(playerid, WHITE, "SYNTAX: /referral [name]");
            SendClientMessage(playerid, GREY, "Type the FULL NAME of your referral, and not an ID");
            SendClientMessage(playerid, GREY, "NOTE: This command is CaSe SeNsItIvE.");
        }
    }
    else
    {
        if(Player[playerid][PlayingHours] >= 0)
        {
            if(strlen(Name) >= 3 && strlen(Name) < MAX_PLAYER_NAME+1)
            {
                format(string2, sizeof(string2), "Accounts/%s.ini", Name);
                if(fexist(string2))
                {
                    if(Player[playerid][PlayingHours] >= 3)
                    {
                        SendClientMessage(playerid, WHITE, "You already have more than two playing hours, you cannot do this anymore!");
                    }
                    else
                    {
                        //reffer = Name;
                        format(string, sizeof(string), "You added %s succesfully as your referral!", Name);
                        SendClientMessage(playerid, WHITE, string);
                        format(string, sizeof(string), "If you had a referral already, that one got replaced!");
                        SendClientMessage(playerid, WHITE, string);
                        format(Player[playerid][Ref], sizeof(string), Name);
                        Player[playerid][Authenticated] = 1;
                    }
                }
                else
                {
                    SendClientMessage(playerid, WHITE, "Account not found. Remember this command is CaSe SeNsEtIvE ");
                }
            }
        }
    }
    return 1;
}
but I believe the problem is that it says the file doesn't excist while it does...
Reply
#7

use dini_Exists

change the line

pawn Код:
if(fexist(string2))
to

pawn Код:
if(dini_Exists(string2))
Reply
#8

P.S. new Referral = Player[i][Ref]; < You can't do something like this. Use 'format'
Reply
#9

Quote:
Originally Posted by stabker
Посмотреть сообщение
P.S. new Referral = Player[i][Ref]; < You can't do something like this. Use 'format'
Can you please write it fully out for me (how I should paste it in the script)

Thanks in advance.
Reply
#10

Quote:
Originally Posted by Supercop
Посмотреть сообщение
Can you please write it fully out for me (how I should paste it in the script)

Thanks in advance.
We need to do something like this:

pawn Код:
new Referral[MAX_PLAYER_NAME];
pawn Код:
format(Referral,sizeof(Referral),"%s",Player[i][Ref]);
or

pawn Код:
strmid(Referral, Player[i][Ref], 0, strlen(Player[i][Ref]), MAX_PLAYER_NAME);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)