SA-MP Forums Archive
Silly and easy question.Urgently please - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Silly and easy question.Urgently please (/showthread.php?tid=243289)



Silly and easy question.Urgently please - SkizzoTrick - 22.03.2011

pawn Код:
new gi1[15];
            new gi2[15];
            new gi3[15];
            new gi4[15];
            new gi5[15];
            new gi6[15];
            if(gitem1[playerid] == 1){ gi1="Phone"; }
            else{ gi1="None"; }
            if(gitem2[playerid] == 1){ gi2="Dice"; }
            else{ gi2="None"; }
            if(gitem3[playerid] == 1){ gi3="Gas Can"; }
            else{ gi3="None"; }
            if(gitem4[playerid] == 1){ gi4="Digital Camera"; }
            else{ gi4="None"; }
            if(gitem5[playerid] == 1){ gi5="Mask"; }
            else{ gi5="None"; }
            if(gitem6[playerid] == 1){ gi6="Rope"; }
            else{ gi6="None"; }
            new sexybiatch[512],string1[50],string2[50],string3[50],string4[50],string5[50],string6[50];
            format(string1,sizeof(string1),"%s Price:%d",gi1,gitem1p[playerid]);
            format(string2,sizeof(string1),"%s Price:%d",gi2,gitem2p[playerid]);
            format(string3,sizeof(string1),"%s Price:%d",gi3,gitem3p[playerid]);
            format(string4,sizeof(string1),"%s Price:%d",gi4,gitem4p[playerid]);
            format(string5,sizeof(string1),"%s Price:%d",gi5,gitem5p[playerid]);
            format(string6,sizeof(string1),"%s Price:%d",gi6,gitem6p[playerid]);
            format(sexybiatch,sizeof(sexybiatch),"%s\n%s\n%s\n%s\n%s\n%s",string1,string2,string3,string4,string5,string6);
            ShowPlayerDialog(playerid,70,DIALOG_STYLE_LIST,"Cart checkout:",sexybiatch,"Buy","Leave");

pawn Код:
if(dialogid == 435)
    {
        if(response)
        {
            new total = gitem1p[playerid]+gitem2p[playerid]+gitem3p[playerid]+gitem4p[playerid]+gitem5p[playerid]+gitem6p[playerid];
            if(GetPlayerMoney(playerid) >= total)
            {
                SendClientMessage(playerid,COLOR_WHITE,"Buying");
                if(gitem1[playerid] == 1)
                {
                    gitem1[playerid] = 0;
                    gitem1p[playerid] = 0;
                    new randphone = 100000 + random(899999);//minimum 1000  max 9999
                    PlayerInfo[playerid][pPnumber] = randphone;
                    GivePlayerMoney(playerid,-gitem1p[playerid]);
                }
                if(gitem2[playerid] == 1)
                {
                    gitem2[playerid] = 0;
                    gitem2p[playerid] = 0;
                    gDice[playerid] = 1;
                    GivePlayerMoney(playerid,-gitem2p[playerid]);
                }
                if(gitem3[playerid] == 1)
                {
                    gitem3[playerid] = 0;
                    gitem3p[playerid] = 0;
                    PlayerInfo[playerid][pFuel] = 20;
                    GivePlayerMoney(playerid,-gitem3p[playerid]);
                }
                if(gitem4[playerid] == 1)
                {
                    gitem4[playerid] = 0;
                    gitem4p[playerid] = 0;
                    GivePlayerMoney(playerid, - 50);
                    GivePlayerWeapon(playerid, 43, 20);
                }
                if(gitem5[playerid] == 1)
                {
                    gitem5[playerid] = 0;
                    gitem5p[playerid] = 0;
                    if(PlayerInfo[playerid][pLevel] < 5)
                    {
                        SendClientMessage(playerid, COLOR_GREY, "You have to be level 5 to buy a mask");
                        return 1;
                    }
                    if(PlayerInfo[playerid][pMask] != 0)
                    {
                        SendClientMessage(playerid, COLOR_GREY, "You already have a mask!");
                        return 1;
                    }
                    if(PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 1)
                    {
                        GameTextForPlayer(playerid, "~w~Free", 5000, 1);
                    }
                    else
                    {
                        GivePlayerMoney(playerid, - 500);
                        format(string, sizeof(string), "~r~-$%d", 500);
                        GameTextForPlayer(playerid, string, 5000, 1);
                    }
                    PlayerInfo[playerid][pMask] = 1;

                }
                if(gitem6[playerid] == 1)
                {
                    gitem6[playerid] = 0;
                    gitem6p[playerid] = 0;
                    if(Rope[playerid] >= 5)
                    {
                        SendClientMessage(playerid, COLOR_GREY, "You have 5 ropes already !");
                        return 1;
                    }
                    GivePlayerMoney(playerid, - 10);
                    Rope[playerid]++;
                }
            }
            else
            {
                SendClientMessage(playerid,COLOR_WHITE,"Not enough funds!");
            }
        }
    }
Nothing happens when i hit "Buy"


Re: Silly and easy question.Urgently please - Biesmen - 22.03.2011

Well, first of all I would replace this stuff gi(number) with this:
pawn Код:
new gi[6][15];
Usage:
pawn Код:
if(gitem1[playerid] == 1){ gi[1]="Phone"; }
Anyway, the reason it won't show up is because the Cart Checkout dialog is ID 70, and you make it check at OnDialogResponse for dialog ID 435, which should be 70.

Also, do the same for your gitem. It's a lot better.
Also, to make string1,2,3,4,5 in one string, you could do that simply by using something like:
pawn Код:
format(string, sizeof(string), "Blabla \
Blablabla \
Blablablabla \
Blablabla \
Bliblablo"
);
If it doesn't work, try something like:
pawn Код:
new string[] = "Blabla \
Blablabla \
Blablablabla \
Blablabla \
Bliblablo"
;
etc


Re: Silly and easy question.Urgently please - Norck - 22.03.2011

pawn Код:
if(dialogid == 435) //Change it to 70
I lol'd at:
pawn Код:
new sexybiatch[512]



Re: Silly and easy question.Urgently please - Biesmen - 22.03.2011

Quote:
Originally Posted by Norck
Посмотреть сообщение
pawn Код:
if(dialogid == 435) //Change it to 70
Thank you for repeating me.


Re: Silly and easy question.Urgently please - Zh3r0 - 22.03.2011

O MY GOD! You know that i can make your first code of 1 line long?


Re: Silly and easy question.Urgently please - SkizzoTrick - 22.03.2011

Quote:
Originally Posted by Zh3r0
Посмотреть сообщение
O MY GOD! You know that i can make your first code of 1 line long?
I kno :P but i like it xD
Thank you so much to everyone.Im just embarassed now for that mistake.
Thanks )


Re: Silly and easy question.Urgently please - -Rebel Son- - 22.03.2011

As biesman said, about using the array, and also with your string. so you dont got string1, string2 etc.

Use it as followed.


Код:
new string[6][15];
Now all you gotta do is

string[0]
string[1]
string[2] and so forth.


Re: Silly and easy question.Urgently please - Zh3r0 - 22.03.2011

Dewdddd, replace your code with this..


pawn Код:
new String[400];
format( String, 400,"%s Price:%d\n\
                     %s Price:%d\n\
                     %s Price:%d\n\
                     %s Price:%d\n\
                     %s Price:%d\n\
                     %s Price:%d\n"
,gitem1[playerid] ? ("Phone")            : ("None"), gitem1[playerid],
                                    gitem2[playerid] ? ("Dice")             : ("None"), gitem2[playerid],
                                    gitem3[playerid] ? ("Gas Can")          : ("None"), gitem3[playerid],
                                    gitem4[playerid] ? ("Digital Camera")   : ("None"), gitem4[playerid],
                                    gitem5[playerid] ? ("Mask")             : ("None"), gitem5[playerid],
                                    gitem6[playerid] ? ("Rope")             : ("None"), gitem6[playerid] );
                                     
            ShowPlayerDialog( playerid, 70, DIALOG_STYLE_LIST, "Cart checkout:",String, "Buy", "Leave" );
Or this:
pawn Код:
new String[400];
format( String, 400,"%s Price:%d\n%s Price:%d\n%s Price:%d\n%s Price:%d\n%s Price:%d\n%s Price:%d\n",gitem1[playerid] ? ("Phone") : ("None"), gitem1[playerid],gitem2[playerid] ? ("Dice") : ("None"), gitem2[playerid],gitem3[playerid] ? ("Gas Can") : ("None"), gitem3[playerid],gitem4[playerid] ? ("Digital Camera"): ("None"), gitem4[playerid],gitem5[playerid] ? ("Mask") : ("None"), gitem5[playerid],gitem6[playerid] ? ("Rope") : ("None"), gitem6[playerid] );

ShowPlayerDialog( playerid, 70, DIALOG_STYLE_LIST, "Cart checkout:",String, "Buy", "Leave" );
I told you i can make it ONE LINE!