Cellphone Number command, greatly appreciated if helped.
#1

Hello SAMP players,
I have some questions here, on how to change this command?

I have this command,
pawn Код:
CMD:buysim(playerid, params[])
{
    new string[128], number, File:file = fopen("cellphones.cfg", io_read);
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(!PlayerInfo[playerid][pHasCellphone]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a cellphone yet.");
    if(!IsPlayerInRangeOfPoint(playerid, 2, 1154.1257,-1180.9600,32.8187)) return SendClientMessage(playerid, COLOR_GREY, "You are not at the Telecom Company.");
    if(sscanf(params, "i", number)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /buysim [desired number]");
    if(number == 0) return SendClientMessage(playerid, COLOR_GREY, "Invalid phone number.");
    if(PlayerInfo[playerid][pCellphone] == number) return SendClientMessage(playerid, COLOR_GREY, "You already have this phone number.");
    new idx = 1;
    while(fread(file, string))
    {
        if(strval(string) == number) return SendClientMessage(playerid, COLOR_GREY, "This number is already registered.");
        if(strval(string) == PlayerInfo[playerid][pCellphone])
        {
            fdeleteline("cellphones.cfg", idx);
        }
        idx ++;
    }
    fclose(file);
    file = fopen("cellphones.cfg", io_append);
    format(string, sizeof(string), "%d | %s\r\n", number, RPN(playerid));
    fwrite(file, string);
    fclose(file);
    format(string, sizeof(string), "* %s has bought a new sim card.", RPN(playerid));
    ProxDetector(15.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    if(!PlayerInfo[playerid][pCellphone])
    {
        SendClientMessage(playerid, COLOR_WHITE, " The company gave you the sim card for free as it's your first.");
        SendClientMessage(playerid, COLOR_WHITE, " You can use /call and /sms now.");
    }
    else
    {
        GiveZaiatMoney(playerid, -500);
        TaxMoney += 500;
        SendClientMessage(playerid, COLOR_WHITE, " The company has charged you $500 for changing your sim card.");
    }
    PlayerInfo[playerid][pCellphone] = number;
    return 1;
}
What I want is,
I want to disable from people buying less than 7 numbers or more than 10 numbers.
Is it even possible to do that?
Or all I need to do is changing this?
pawn Код:
if(number == 0) return SendClientMessage(playerid, COLOR_GREY, "Invalid phone number.");
to
pawn Код:
if(number < 7 && > 10) return SendClientMessage(playerid, COLOR_GREY, "Numbers are between 7 and 10!");
or
pawn Код:
if(number < 1000000 && > 1000000000) return SendClientMessage(playerid, COLOR_GREY, "Numbers are between 7 and 10!");

Hope to see a great reply, thanks.
Everyone who post an answer, will be added rep.
Reply
#2

If you want to disable that people will not able to buy numbers less then 7 and greater then 10. Use this.

pawn Код:
if(number < 1 && > 20) return SendClientMessage(playerid, COLOR_GREY, "Numbers are between 1 and 20!");
Or Just dont use this line!
Reply
#3

Код:
D:\SA-MP\Unlimited Gaming Roleplay\gamemodes\ugrp.pwn(9649) : error 029: invalid expression, assumed zero
D:\SA-MP\Unlimited Gaming Roleplay\gamemodes\ugrp.pwn(9649) : warning 215: expression has no effect
D:\SA-MP\Unlimited Gaming Roleplay\gamemodes\ugrp.pwn(9649) : error 001: expected token: ";", but found ")"
D:\SA-MP\Unlimited Gaming Roleplay\gamemodes\ugrp.pwn(9649) : error 029: invalid expression, assumed zero
D:\SA-MP\Unlimited Gaming Roleplay\gamemodes\ugrp.pwn(9649) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
hmmph.. wonder why the line give that errors?

pawn Код:
CMD:buysim(playerid, params[])
{
    new string[128], number, File:file = fopen("cellphones.cfg", io_read);
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(!PlayerInfo[playerid][pHasCellphone]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a cellphone yet.");
    if(!IsPlayerInRangeOfPoint(playerid, 2, 1154.1257,-1180.9600,32.8187)) return SendClientMessage(playerid, COLOR_GREY, "You are not at the Telecom Company.");
    if(sscanf(params, "i", number)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /buysim [desired number]");
    if(number < 1 && > 20) return SendClientMessage(playerid, COLOR_GREY, "Numbers are between 1 and 20!"); // This Line
    if(PlayerInfo[playerid][pCellphone] == number) return SendClientMessage(playerid, COLOR_GREY, "You already have this phone number.");
    new idx = 1;
    while(fread(file, string))
    {
        if(strval(string) == number) return SendClientMessage(playerid, COLOR_GREY, "This number is already registered.");
        if(strval(string) == PlayerInfo[playerid][pCellphone])
        {
            fdeleteline("cellphones.cfg", idx);
        }
        idx ++;
    }
    fclose(file);
    file = fopen("cellphones.cfg", io_append);
    format(string, sizeof(string), "%d | %s\r\n", number, RPN(playerid));
    fwrite(file, string);
    fclose(file);
    format(string, sizeof(string), "* %s has bought a new sim card.", RPN(playerid));
    ProxDetector(15.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    if(!PlayerInfo[playerid][pCellphone])
    {
        SendClientMessage(playerid, COLOR_WHITE, " The company gave you the sim card for free as it's your first.");
        SendClientMessage(playerid, COLOR_WHITE, " You can use /call and /sms now.");
    }
    else
    {
        GiveZaiatMoney(playerid, -500);
        TaxMoney += 500;
        SendClientMessage(playerid, COLOR_WHITE, " The company has charged you $500 for changing your sim card.");
    }
    PlayerInfo[playerid][pCellphone] = number;
    return 1;
}
Reply
#4

Show me the line 9649.
Reply
#5

pawn Код:
if(number < 1 && > 20) return SendClientMessage(playerid, COLOR_GREY, "Numbers are between 1 and 20!"); // This Line
Reply
#6

pawn Код:
CMD:buysim(playerid, params[])
{
    new string[128], number, File:file = fopen("cellphones.cfg", io_read);
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(!PlayerInfo[playerid][pHasCellphone]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a cellphone yet.");
    if(!IsPlayerInRangeOfPoint(playerid, 2, 1154.1257,-1180.9600,32.8187)) return SendClientMessage(playerid, COLOR_GREY, "You are not at the Telecom Company.");
    if(sscanf(params, "i", number)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /buysim [desired number]");
    if(PlayerInfo[playerid][pCellphone] == number) return SendClientMessage(playerid, COLOR_GREY, "You already have this phone number.");
    new idx = 1;
    while(fread(file, string))
    {
        if(strval(string) == number) return SendClientMessage(playerid, COLOR_GREY, "This number is already registered.");
        if(strval(string) == PlayerInfo[playerid][pCellphone])
        {
            fdeleteline("cellphones.cfg", idx);
        }
        idx ++;
    }
    fclose(file);
    file = fopen("cellphones.cfg", io_append);
    format(string, sizeof(string), "%d | %s\r\n", number, RPN(playerid));
    fwrite(file, string);
    fclose(file);
    format(string, sizeof(string), "* %s has bought a new sim card.", RPN(playerid));
    ProxDetector(15.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    if(!PlayerInfo[playerid][pCellphone])
    {
        SendClientMessage(playerid, COLOR_WHITE, " The company gave you the sim card for free as it's your first.");
        SendClientMessage(playerid, COLOR_WHITE, " You can use /call and /sms now.");
    }
    else
    {
        GiveZaiatMoney(playerid, -500);
        TaxMoney += 500;
        SendClientMessage(playerid, COLOR_WHITE, " The company has charged you $500 for changing your sim card.");
    }
    PlayerInfo[playerid][pCellphone] = number;
    return 1;
}
Reply
#7

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
pawn Код:
CMD:buysim(playerid, params[])
{
    new string[128], number, File:file = fopen("cellphones.cfg", io_read);
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(!PlayerInfo[playerid][pHasCellphone]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a cellphone yet.");
    if(!IsPlayerInRangeOfPoint(playerid, 2, 1154.1257,-1180.9600,32.8187)) return SendClientMessage(playerid, COLOR_GREY, "You are not at the Telecom Company.");
    if(sscanf(params, "i", number)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /buysim [desired number]");
    if(PlayerInfo[playerid][pCellphone] == number) return SendClientMessage(playerid, COLOR_GREY, "You already have this phone number.");
    new idx = 1;
    while(fread(file, string))
    {
        if(strval(string) == number) return SendClientMessage(playerid, COLOR_GREY, "This number is already registered.");
        if(strval(string) == PlayerInfo[playerid][pCellphone])
        {
            fdeleteline("cellphones.cfg", idx);
        }
        idx ++;
    }
    fclose(file);
    file = fopen("cellphones.cfg", io_append);
    format(string, sizeof(string), "%d | %s\r\n", number, RPN(playerid));
    fwrite(file, string);
    fclose(file);
    format(string, sizeof(string), "* %s has bought a new sim card.", RPN(playerid));
    ProxDetector(15.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    if(!PlayerInfo[playerid][pCellphone])
    {
        SendClientMessage(playerid, COLOR_WHITE, " The company gave you the sim card for free as it's your first.");
        SendClientMessage(playerid, COLOR_WHITE, " You can use /call and /sms now.");
    }
    else
    {
        GiveZaiatMoney(playerid, -500);
        TaxMoney += 500;
        SendClientMessage(playerid, COLOR_WHITE, " The company has charged you $500 for changing your sim card.");
    }
    PlayerInfo[playerid][pCellphone] = number;
    return 1;
}
basically, you removed the line, so how could it detect if they're buying less than 7 digit numbers or more than 10?
What I wanted was, I want, like, you need to buy phone number which has more than 7 digit numbers and less than 10, so they wont have nonrp numbers, like '1', '666', '1337', and stuffs.
Reply
#8

Quote:
Originally Posted by Ahrim
Посмотреть сообщение
basically, you removed the line, so how could it detect if they're buying less than 7 digit numbers or more than 10?
What I wanted was, I want, like, you need to buy phone number which has more than 7 digit numbers and less than 10, so they wont have nonrp numbers, like '1', '666', '1337', and stuffs.
pawn Код:
CMD:buysim(playerid, params[])
{
    new string[128], number, File:file = fopen("cellphones.cfg", io_read);
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(!PlayerInfo[playerid][pHasCellphone]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a cellphone yet.");
    if(!IsPlayerInRangeOfPoint(playerid, 2, 1154.1257,-1180.9600,32.8187)) return SendClientMessage(playerid, COLOR_GREY, "You are not at the Telecom Company.");
    if(sscanf(params, "i", number)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /buysim [desired number]");
    if(number <= 6 || number >= 11) return SendClientMessage(playerid, COLOR_GREY, "The number should be more then 6 Characters and less then 11");
    if(PlayerInfo[playerid][pCellphone] == number) return SendClientMessage(playerid, COLOR_GREY, "You already have this phone number.");
    new idx = 1;
    while(fread(file, string))
    {
        if(strval(string) == number) return SendClientMessage(playerid, COLOR_GREY, "This number is already registered.");
        if(strval(string) == PlayerInfo[playerid][pCellphone])
        {
            fdeleteline("cellphones.cfg", idx);
        }
        idx ++;
    }
    fclose(file);
    file = fopen("cellphones.cfg", io_append);
    format(string, sizeof(string), "%d | %s\r\n", number, RPN(playerid));
    fwrite(file, string);
    fclose(file);
    format(string, sizeof(string), "* %s has bought a new sim card.", RPN(playerid));
    ProxDetector(15.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    if(!PlayerInfo[playerid][pCellphone])
    {
        SendClientMessage(playerid, COLOR_WHITE, " The company gave you the sim card for free as it's your first.");
        SendClientMessage(playerid, COLOR_WHITE, " You can use /call and /sms now.");
    }
    else
    {
        GiveZaiatMoney(playerid, -500);
        TaxMoney += 500;
        SendClientMessage(playerid, COLOR_WHITE, " The company has charged you $500 for changing your sim card.");
    }
    PlayerInfo[playerid][pCellphone] = number;
    return 1;
}
Reply
#9

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
pawn Код:
CMD:buysim(playerid, params[])
{
    new string[128], number, File:file = fopen("cellphones.cfg", io_read);
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(!PlayerInfo[playerid][pHasCellphone]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a cellphone yet.");
    if(!IsPlayerInRangeOfPoint(playerid, 2, 1154.1257,-1180.9600,32.8187)) return SendClientMessage(playerid, COLOR_GREY, "You are not at the Telecom Company.");
    if(sscanf(params, "i", number)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /buysim [desired number]");
    if(number <= 6 || number >= 11) return SendClientMessage(playerid, COLOR_GREY, "The number should be more then 6 Characters and less then 11");
    if(PlayerInfo[playerid][pCellphone] == number) return SendClientMessage(playerid, COLOR_GREY, "You already have this phone number.");
    new idx = 1;
    while(fread(file, string))
    {
        if(strval(string) == number) return SendClientMessage(playerid, COLOR_GREY, "This number is already registered.");
        if(strval(string) == PlayerInfo[playerid][pCellphone])
        {
            fdeleteline("cellphones.cfg", idx);
        }
        idx ++;
    }
    fclose(file);
    file = fopen("cellphones.cfg", io_append);
    format(string, sizeof(string), "%d | %s\r\n", number, RPN(playerid));
    fwrite(file, string);
    fclose(file);
    format(string, sizeof(string), "* %s has bought a new sim card.", RPN(playerid));
    ProxDetector(15.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    if(!PlayerInfo[playerid][pCellphone])
    {
        SendClientMessage(playerid, COLOR_WHITE, " The company gave you the sim card for free as it's your first.");
        SendClientMessage(playerid, COLOR_WHITE, " You can use /call and /sms now.");
    }
    else
    {
        GiveZaiatMoney(playerid, -500);
        TaxMoney += 500;
        SendClientMessage(playerid, COLOR_WHITE, " The company has charged you $500 for changing your sim card.");
    }
    PlayerInfo[playerid][pCellphone] = number;
    return 1;
}
now I get it, the line
pawn Код:
if(number <= 6 || number >= 11) return SendClientMessage(playerid, COLOR_GREY, "The number should be more then 6 Characters and less then 11");
defines the NUMBER, not the amount of character.
like, the line now, <=6 and >=11, I can only buy number 7,8,9,10, not the amount, but the exact number..
help will be appreciated.
Reply
#10

Oh My i didnt notice that. Do one thing. Replace it like this : number <= 1000000 || number >= 99999999
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)