SA-MP Forums Archive
please dont ignore this! - 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)
+--- Thread: please dont ignore this! (/showthread.php?tid=612742)



please dont ignore this! - MayaEU - 21.07.2016

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


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;
    }



Re: please dont ignore this! - UltraScripter - 21.07.2016

Do you do like this:
PHP код:
CMD:yourcmd(playeridparams)
{
     
//your code
     
return 0// if you do return 0 it will send that change it to return 1; 




Re: please dont ignore this! - MayaEU - 21.07.2016

Quote:
Originally Posted by UltraScripter
Посмотреть сообщение
Do you do like this:
PHP код:
CMD:yourcmd(playeridparams)
{
     
//your code
     
return 0// if you do return 0 it will send that change it to return 1; 

Well i have just fixed the "Unknown Command" thing myself, but the problem is still that it
doesnt say the fishname in the cooler, still just the beginning letter.


Re: please dont ignore this! - oktokt1 - 21.07.2016

show the codes..


Re: please dont ignore this! - MayaEU - 21.07.2016

OnPlayerConnect
pawn Код:
pCoolerType[playerid][1] = 0;
    pCoolerType[playerid][2] = 0;
    pCoolerType[playerid][3] = 0;
    pCoolerType[playerid][4] = 0;
    pCoolerType[playerid][5] = 0;
    pCoolerValue[playerid][1] = 0;
    pCoolerValue[playerid][2] = 0;
    pCoolerValue[playerid][3] = 0;
    pCoolerValue[playerid][4] = 0;
    pCoolerValue[playerid][5] = 0;



Re: please dont ignore this! - Calgon - 21.07.2016

You need to show the code for your command, not just a small segment. How do you expect us to help you without seeing your code?


Re: please dont ignore this! - MayaEU - 21.07.2016

Quote:
Originally Posted by Calgon
Посмотреть сообщение
You need to show the code for your command, not just a small segment. How do you expect us to help you without seeing your code?
Omg, im so sorry, i thought that i did already put the code ^^


here it is
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;
    }



Re: please dont ignore this! - FuNkYTheGreat - 21.07.2016

PHP код:
    if(strcmp(cmd,"/cooler",true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            if(
PlayerInfo[playerid][pCooler] == 0)
                {
                
SendClientMessage(playerid0xAFAFAFAA"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 >= && slot <= coolerslots)
                        {
                            switch(
pCoolerType[playerid][slot])
                            {
                                case 
1:
                                {
                                    
format(stringsizeof(string), "* %s takes a %s from his cooler."MaskOnOff(playerid),pCoolerValue[playerid][slot]);
                                    
ProxDetector(30.0playeridstringCOLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED);
                                    
Fishes[playerid][pFish] = pCoolerValue[playerid][slot];
                                    
pCoolerType[playerid][slot] = 0;
                                    
pCoolerValue[playerid][slot] = 0;
                                }
                                default:
                                {
                                    
SendClientMessage(playerid,COLOR_GREY,"There's no fish there for you to take!");
                                }
                            }
                        }
                    }
                    
format(string,sizeof(string),""COL_SZR"Usage:"COL_WHITE" /cooler take <1-5>");
                    
SendClientMessage(playerid,COLOR_GREY,string);
                }
                else if(
strcmp(tmp,"store",true) == 0)
                {
                    new 
emptyslot;
                    for(new 
1;<= coolerslots;i++)
                    {
                        if(
pCoolerType[playerid][i] == 0)
                        {
                           
emptyslot i;
                           break;
                        }
                    }
                    if(!
emptyslot)
                    {
                        
SendClientMessage(playerid,COLOR_GREY," Your cooler is full!");
                    }
                    if(
Fishes[playerid][pFish] == 0)
                                        {
                        
SendClientMessage(playeridCOLOR_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(stringsizeof(string), "* %s puts a %s in his cooler."MaskOnOff(playerid),Fishes[playerid][pFish]);
                    
ProxDetector(30.0playeridstringCOLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED);
                }
            }
            
SendClientMessage(playerid0xAFAFAFAA"Your Styrofoam cooler contains:");
            for(new 
1;<= 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(playerid0xAFAFAFAA""COL_SZR"Usage:"COL_WHITE" /cooler <store|take>");
        }
        return 
1;
    } 



Re: please dont ignore this! - DRIFT_HUNTER - 21.07.2016

pawn Код:
for(new i = 1;i <= coolerslots;i++)
//to
for(new i = 0;i < coolerslots;i++)
There is at least two loops (so replace in two places)


Re: please dont ignore this! - MayaEU - 21.07.2016

Quote:
Originally Posted by FuNkYTheGreat
Посмотреть сообщение
PHP код:
    if(strcmp(cmd,"/cooler",true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            if(
PlayerInfo[playerid][pCooler] == 0)
                {
                
SendClientMessage(playerid0xAFAFAFAA"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 >= && slot <= coolerslots)
                        {
                            switch(
pCoolerType[playerid][slot])
                            {
                                case 
1:
                                {
                                    
format(stringsizeof(string), "* %s takes a %s from his cooler."MaskOnOff(playerid),pCoolerValue[playerid][slot]);
                                    
ProxDetector(30.0playeridstringCOLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED);
                                    
Fishes[playerid][pFish] = pCoolerValue[playerid][slot];
                                    
pCoolerType[playerid][slot] = 0;
                                    
pCoolerValue[playerid][slot] = 0;
                                }
                                default:
                                {
                                    
SendClientMessage(playerid,COLOR_GREY,"There's no fish there for you to take!");
                                }
                            }
                        }
                    }
                    
format(string,sizeof(string),""COL_SZR"Usage:"COL_WHITE" /cooler take <1-5>");
                    
SendClientMessage(playerid,COLOR_GREY,string);
                }
                else if(
strcmp(tmp,"store",true) == 0)
                {
                    new 
emptyslot;
                    for(new 
1;<= coolerslots;i++)
                    {
                        if(
pCoolerType[playerid][i] == 0)
                        {
                           
emptyslot i;
                           break;
                        }
                    }
                    if(!
emptyslot)
                    {
                        
SendClientMessage(playerid,COLOR_GREY," Your cooler is full!");
                    }
                    if(
Fishes[playerid][pFish] == 0)
                                        {
                        
SendClientMessage(playeridCOLOR_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(stringsizeof(string), "* %s puts a %s in his cooler."MaskOnOff(playerid),Fishes[playerid][pFish]);
                    
ProxDetector(30.0playeridstringCOLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED);
                }
            }
            
SendClientMessage(playerid0xAFAFAFAA"Your Styrofoam cooler contains:");
            for(new 
1;<= 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(playerid0xAFAFAFAA""COL_SZR"Usage:"COL_WHITE" /cooler <store|take>");
        }
        return 
1;
    } 
Not working. The problem is also, that, when you look inside the cooler it doenst show the name of the fish.
only the beginning letter for the last stored fish