Attempting to Create a Phone System
#1

I have two Dialogs One for the Electronics store to purchase various phones, The other for Service, Ulimited everything service, or prepaid service. under where it says "Case 0, Case 1, ect....." Can someone let me know what i would put to help store the variables, to let the system know the player purchased a phone, and service or minutes?

Notes: I use Y_INI

Enum
pawn Код:
enum pInfo
{
pPass,
pLevel,
pExp,
pCash,
pSex,
pAge,
pSkin,
pLeader,
pRank,
pTeam,
pMember,
pAdmin,
pVip,
pMuted,
pTut,
pMuteTime,//  Bugged At the Moment
pLocked,
pHasAPhone,
pPhoneType,
pPhoneService,
pNumber,
pKills,
pDeaths,
}
Dialogs
pawn Код:
case DIALOG_ESTORE:
        {
            if( !response ) return 0;
            if( response )
            {
                switch( listitem )
                {
                    case 0:// HTC Evo Phone
                    {
                        if(GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                        GivePlayerMoney(playerid, -500);
                        SendClientMessage(playerid, 0xFFFFFF, "Congratulations you just purchased a HTC Evo with 4G internet speed. /service to activate your new phone.");
//Do something here to save the players data saying the player now has phone type 1
                    }
                    case 1: // Iphone
                    {
                        if(GetPlayerMoney(playerid) < 2) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                        GivePlayerMoney(playerid, -5);
                        SendClientMessage(playerid, 0xFFFFFF, "Congratulations you just purchased a Iphone with 4G internet speed. /service to activate your new phone.");
//Do something here to save the players data saying the player now has phone type 2
                    }
                    case 2: // Samsung Galaxy SII
                    {
                        if(GetPlayerMoney(playerid) < 2) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                        GivePlayerMoney(playerid, -5);
                        SendClientMessage(playerid, 0xFFFFFF, "Congratulations you just purchased a Samsung Galaxy SII with 3G internet speed. /service to activate your new phone.");
//Do something here to save the players data saying the player now has phone type 3
                    }
                    case 3: // Prepaid
                    {
                        if(GetPlayerMoney(playerid) < 2) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                        GivePlayerMoney(playerid, -5);
                        SendClientMessage(playerid, 0xFFFFFF, "Congratulations you just purchased a Prepid Rumor 2. /service to buy Minutes.");
//Do something here to save the players data saying the player now has phone type 4
                    }
                }
            }
        }
        case DIALOG_SERVICE:
        {
            if( !response ) return 0;
            if( response )
            {
                switch( listitem )
                {
                    case 0:// Sprint Contract
                    {
                        if(GetPlayerMoney(playerid) < 85) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                        GivePlayerMoney(playerid, -85);
                        SendClientMessage(playerid, 0xFFFFFF, "You just signed a contract with Sprint for your Unlimited plan.");
                        SendClientMessage(playerid, 0xFFFFFF, "85.00$ Will be deducted from your account every month(payday).");
                        SendClientMessage(playerid, 0xFFFFFF, "Failure to pay your bill will result in disconnection, and reconnection fees.");
//Do something here to save the players data saying the player now has service type 1
                    }
                    case 1: // AT&T Contract
                    {
                        if(GetPlayerMoney(playerid) < 90) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                        GivePlayerMoney(playerid, -90);
                        SendClientMessage(playerid, 0xFFFFFF, "You just signed a contract with AT&T for your Unlimited plan.");
                        SendClientMessage(playerid, 0xFFFFFF, "90.00$ Will be deducted from your account every month(payday).");
                        SendClientMessage(playerid, 0xFFFFFF, "Failure to pay your bill will result in disconnection, and reconnection fees.");
//Do something here to save the players data saying the player now has service type 2
                    }
                    case 2: // Boost Mobile Contract
                    {
                        if(GetPlayerMoney(playerid) < 50) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                        GivePlayerMoney(playerid, -50);
                        SendClientMessage(playerid, 0xFFFFFF, "You just signed a contract with BoostMobile for your Unlimited plan.");
                        SendClientMessage(playerid, 0xFFFFFF, "50.00$ Will be deducted from your account every month(payday).");
                        SendClientMessage(playerid, 0xFFFFFF, "Failure to pay your bill will result in disconnection, and reconnection fees.");
//Do something here to save the players data saying the player now has service type 3
                    }
                    case 3: // Prepaid Minutes
                    {
                        if(GetPlayerMoney(playerid) < 20) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                        GivePlayerMoney(playerid, -20);
                        SendClientMessage(playerid, 0xFFFFFF, "You just purchased some minutes for your prepaid phone.");
                        SendClientMessage(playerid, 0xFFFFFF, "If you run out of minutes, you wont recieve any calls or text messages untill replenished.");
//Do something here to save the players data saying the player now has service type 4

                    }
                }
            }
        }
Reply
#2

pPhone, default = -1 (No Phone) if variable is not -1 then the user has a phone, use that in checks, pService just integers, pretty self explanitory and pCreditLeft just remove from it everytime someone hangs up the phone if 0 or below 0 then credit has ran out and alert them.
Reply
#3

Yes but under where i have
pawn Код:
//Do something here to save the players data saying the player now has service type 2
How would the code look? would i be using the
pawn Код:
INI_WriteInt(File,"Logged",PlayerInfo[playerid][pConnected]= 0);
or
pawn Код:
PlayerInfo[playerid][pHasAPhone] = 1);
or what?
Reply
#4

Quote:
Originally Posted by SantarioLeone
Посмотреть сообщение
Yes but under where i have
pawn Код:
//Do something here to save the players data saying the player now has service type 2
How would the code look? would i be using the
pawn Код:
INI_WriteInt(File,"Logged",PlayerInfo[playerid][pConnected]= 0);
or
pawn Код:
PlayerInfo[playerid][pHasAPhone] = 1);
or what?
What?

You do both, you save upon disconnect and load upon login with the file functions into the variable.

PlayerInfo[playerid][pPhone]

-1 = No Phone.
0 = Iphone.
1 = Samsung Galaxy etc
Reply
#5

Like this?
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    SaveUserData(playerid);
    return 1;
}
pawn Код:
public SaveUserData(playerid)
{
    new PlayerName[MAX_PLAYERS];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Level",PlayerInfo[playerid][pLevel]);
    INI_WriteInt(File, "Respect", PlayerInfo[playerid][pExp]);
    GetPlayerMoney(playerid);
    INI_WriteInt(File,"Cash",PlayerInfo[playerid][pCash]);
    INI_WriteInt(File,"Sex",PlayerInfo[playerid][pSex]);
    INI_WriteInt(File,"Age",PlayerInfo[playerid][pAge]);
    GetPlayerSkin(playerid);
    INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
    INI_WriteInt(File,"Leader",PlayerInfo[playerid][pLeader]);
    INI_WriteInt(File,"Rank",PlayerInfo[playerid][pRank]);
    INI_WriteInt(File,"Team",PlayerInfo[playerid][pTeam]);
    INI_WriteInt(File,"Member",PlayerInfo[playerid][pMember]);
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Vip",PlayerInfo[playerid][pVip]);
    INI_WriteInt(File,"Muted",PlayerInfo[playerid][pMuted]);
    INI_WriteInt(File,"Tutorial",PlayerInfo[playerid][pTut]);
    INI_WriteInt(File,"Mute Time",PlayerInfo[playerid][pMuteTime]);
    INI_WriteInt(File,"Banned",PlayerInfo[playerid][pLocked]);
    INI_WriteInt(File,"HasAPhone",PlayerInfo[playerid][pHasAPhone]);
    INI_WriteInt(File,"Number",PlayerInfo[playerid][pNumber]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Close(File);
    printf("[True:RP] %s User Data Has Been Updated In The Database.", PlayerName);
    return 1;
}
pawn Код:
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Level",PlayerInfo[playerid][pLevel]);
    INI_Int("Exp",PlayerInfo[playerid][pExp]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Sex",PlayerInfo[playerid][pSex]);
    INI_Int("Age",PlayerInfo[playerid][pCash]);
    INI_Int("Skin",PlayerInfo[playerid][pCash]);
    INI_Int("Leader",PlayerInfo[playerid][pLeader]);
    INI_Int("Rank",PlayerInfo[playerid][pRank]);
    INI_Int("Team",PlayerInfo[playerid][pTeam]);
    INI_Int("Member",PlayerInfo[playerid][pMember]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("VIP",PlayerInfo[playerid][pVip]);
    INI_Int("Muted",PlayerInfo[playerid][pMuted]);
    INI_Int("Tutorial",PlayerInfo[playerid][pTut]);
    INI_Int("Mute Time",PlayerInfo[playerid][pMuteTime]);
    INI_Int("Banned",PlayerInfo[playerid][pLocked]);
    INI_Int("HasAPhone",PlayerInfo[playerid][pHasAPhone]);
    INI_Int("Number",PlayerInfo[playerid][pNumber]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Level",1);
                INI_WriteInt(File, "Respect", PlayerInfo[playerid][pExp] = 0);
                INI_WriteInt(File,"Cash", PlayerInfo[playerid][pCash] = 10000);
                INI_WriteInt(File,"Sex",0);
                INI_WriteInt(File,"Age",0);
                INI_WriteInt(File,"Skin",0);
                INI_WriteInt(File,"Leader",0);
                INI_WriteInt(File,"Rank",0);
                INI_WriteInt(File,"Team",0);
                INI_WriteInt(File,"Member",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"VIP",0);
                INI_WriteInt(File,"Muted",0);
                INI_WriteInt(File,"Tutorial",0);
                INI_WriteInt(File,"Mute Time",0);
                INI_WriteInt(File,"Banned",0);
                INI_WriteInt(File,"HasAPhone", PlayerInfo[playerid][pHasAPhone] = -1);
                INI_WriteInt(File,"Number",PlayerInfo[playerid][pNumber] = 0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_Close(File);
                new sex[] = " Male \n Female ";
                ShowPlayerDialog(playerid, DIALOG_SEX, DIALOG_STYLE_LIST, "Please selecet your Gender", sex, "Select","Quit Game");
            }
        }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)