A very annoying problem!
#1

Well when i type /cooler, it will not show the name of the fish, only the beginning letter
of the last stored fish. Example, if the last fish i catch is a tuna, it will show "t" in the cooler

I really hope thay anyone can help me rep+

And this is an example, when the cooler is full, that is four diffrent fishes


I have this on top of the gamemode:
pawn Код:
new pCoolerValue[MAX_PLAYERS][6];
And this on OnplayerConnect:
pawn Код:
pCoolerValue[playerid][1] = 0;
    pCoolerValue[playerid][2] = 0;
    pCoolerValue[playerid][3] = 0;
    pCoolerValue[playerid][4] = 0;
    pCoolerValue[playerid][5] = 0;
The command
pawn Код:
if(strcmp(cmd,"/cooler",true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pCooler] == 0)
                return SendClientMessage(playerid, 0xAFAFAFAA, "You don't have a cooler! Buy one at 24/7.");
            new coolerslots;
            if(PlayerInfo[playerid][pCooler] == 1)
            {
                coolerslots = 5;
            }

            tmp = strtok(cmdtext,idx);
            if(strlen(tmp))
            {
                if(strcmp(tmp,"take",true) == 0)
                {
                    tmp = strtok(cmdtext,idx);
                    if(strlen(tmp))
                    {
                        new slot = strval(tmp);
                        if(slot >= 1 && slot <= coolerslots)
                        {
                            switch(pCoolerType[playerid][slot])
                            {
                                case 1:
                                {
                                    format(string, sizeof(string), "* %s takes a %s from his cooler.", MaskOnOff(playerid),pCoolerValue[playerid][slot]);
                                    ProxDetector(30.0, playerid, string, COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED);
                                    Fishes[playerid][pFish] = pCoolerValue[playerid][slot];
                                    pCoolerType[playerid][slot] = 0;
                                    pCoolerValue[playerid][slot] = 0;
                                    return 1;
                                }
                                default:
                                {
                                    SendClientMessage(playerid,COLOR_GREY,"There's no fish there for you to take!");
                                    return 1;
                                }
                            }
                        }
                    }
                    format(string,sizeof(string),""COL_SZR"Usage:"COL_WHITE" /cooler take <1-5>");
                    SendClientMessage(playerid,COLOR_GREY,string);

                    return 1;
                }
                else if(strcmp(tmp,"store",true) == 0)
                {
                    new emptyslot;
                    for(new i = 1;i <= coolerslots;i++)
                    {
                        if(pCoolerType[playerid][i] == 0)
                        {
                        emptyslot = i;
                        break;
                        }
                    }
                    if(!emptyslot)
                    {
                        return SendClientMessage(playerid,COLOR_GREY," Your cooler is full!");
                    }
                    if(Fishes[playerid][pFish] == 0)
                        return SendClientMessage(playerid, COLOR_GREY, "You don't have a fish to put in your cooler!");
                    tmp = strtok(cmdtext,idx);
                    pCoolerType[playerid][emptyslot] = 1;
                    pCoolerValue[playerid][emptyslot] = Fishes[playerid][pFish];
                    format(string, sizeof(string), "* %s puts a %s in his cooler.", MaskOnOff(playerid),Fishes[playerid][pFish]);
                    ProxDetector(30.0, playerid, string, COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED);
                    return 1;
                }
            }
            SendClientMessage(playerid, 0xAFAFAFAA, "Your Styrofoam cooler contains:");
            for(new i = 1;i <= coolerslots;i++)
            {
                switch(pCoolerType[playerid][i])
                {
                    case 1:  { format(string,sizeof(string),"%d. %s",i,pCoolerValue[playerid][i]); }
                    case 2:  { format(string,sizeof(string),"%d. %s)",i,pCoolerValue[playerid][i]); }
                    case 3:  { format(string,sizeof(string),"%d. %s)",i,pCoolerValue[playerid][i]); }
                    case 4:  { format(string,sizeof(string),"%d. %s)",i,pCoolerValue[playerid][i]); }
                    case 5:  { format(string,sizeof(string),"%d. %s)",i,pCoolerValue[playerid][i]); }
                    default: { format(string,sizeof(string),"%d. None",i); }
                }
                SendClientMessage(playerid,COLOR_GREY,string);
            }
            SendClientMessage(playerid, 0xAFAFAFAA, ""COL_SZR"Usage:"COL_WHITE" /cooler <store|take>");
            return 1;
        }
        return 1;
    }
Reply
#2

Do you want pCoolerValue to be an array of integers or strings?
Reply
#3

Quote:
Originally Posted by Freaksken
Посмотреть сообщение
Do you want pCoolerValue to be an array of integers or strings?
Just so it will show the whole fishnames
Reply
#4

The way you have pCoolerValue now, you store it with integers.
Can I see your Fishes declaration?
Reply
#5

Of course

pawn Код:
enum pFishing
{
    pFish[20],
    pWeight,
    pTempFish[20],
    pTempWeight,
    pFishHold,
    pTempFishHold,
    pTempFishName,
    pFishPrice,
    pTempFishPrice,
    pLastFish,
    pFishID,
    pLastWeight,
};
new Fishes[MAX_PLAYERS][pFishing];
Reply
#6

Is pFish or pTempFish the fish's name?
Reply
#7

No the pTempFish is just a second fish that you can throw away, but its the pFish that it will store into the cooler
Reply
#8

Quote:
Originally Posted by Freaksken
Посмотреть сообщение
Is pFish or pTempFish the fish's name?
Oh, sorry i did misread what you said.. Yes, pFish is the fish's name
Reply
#9

Ok, so if you want to store the fish's name in pCoolerValue, you will need to use this:
Код:
new pCoolerValue[MAX_PLAYERS][6][20];
format(string, sizeof(string), "%s", pCoolerValue[playerid][slot]);
And if you want to identify the fish by an ID, you will have to rewrite a lot of your code.

EDIT:
Take a look at some of your code where you do this:
Код:
pCoolerValue[playerid][slot] = 0; //You assign an integer here!
Reply
#10

Quote:
Originally Posted by Freaksken
Посмотреть сообщение
Ok, so if you want to store the fish's name in pCoolerValue, you will need to use this:
Код:
new pCoolerValue[MAX_PLAYERS][6][20];
format(string, sizeof(string), "%s", pCoolerValue[playerid][slot]);
And if you want to identify the fish by an ID, you will have to rewrite a lot of your code.
Okay so i Will have to put that on top of the gamemode?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)