error 001: expected token: "-identifier-", but found "-integer value-"
#1

How can i make the command like this? /sellmats [id] [type] [amount] [price]. Thank you!

material type should be only "A, B and C" small and capital letters are accepted.

Quote:

CMDellmats(playerid, params[])
{
if(Player[playerid][Admin] >= 1)
{
SendClientMessage(playerid,COLOR_WHITE, "Administrators can't use this command.");
return 1;
}

new string[128];

if(GetPVarInt(playerid, "SellMatsTimer") > 0)
{
format(string, sizeof(string), "You must wait %d seconds before selling more materials.", GetPVarInt(playerid, "SellMatsTimer"));
SendClientMessage(playerid, COLOR_GREY, string);
return 1;
}

new giveplayerid, amount, material[1], price;

if(sscanf(params, "udud", giveplayerid, material, amount, price)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sellmats [playerid/partofname] [material] [amount] [price]");

if(amount < 1)
{
SendClientMessage(playerid, COLOR_GREY, "Materials amount must be no lower than 1!");
return 1;
}
if (material != "a" || material != "A" || material != "b" || material != "B" || material != "c" || material != "C")
{
SendClientMessage(playerid, COLOR_GREY, "Invalid material class.");
return 1;
}
if(price < 5000)
{
SendClientMessage(playerid, COLOR_GREY, "Price must be no lower than $5000.");
return 1;
}
if(amount > Player[playerid][MatsA] || amount > Player[playerid][MatsB] || amount > Player[playerid][MatsC])
{
SendClientMessage(playerid, COLOR_GREY, "You don't have that many materials!");
return 1;
}

if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
if(ProxDetectorS(8.0, playerid, giveplayerid))
{
if(giveplayerid == playerid)
{
SendClientMessage(playerid, COLOR_GREY, "You can't sell materials to yourself!");
return 1;
}
format(string, sizeof(string), "* You offered %s to buy %d class %s materials for $%d.", GetPlayerName(giveplayerid), amount, material, price);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "* %s wants to sell you %d class %s materials for $%d, (type /accept mats) to buy.", GetPlayerName(playerid), amount, material, price);
SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);

SetPVarInt(playerid, "SellMatsTimer", 30);
SetTimerEx("OtherTimerEx", 1000, false, "ii", playerid, TYPE_SELLMATSTIMER);

MatsOffer[giveplayerid] = playerid;
MatsPrice[giveplayerid] = price;
MatsType[giveplayerid] = material;
MatsAmount[giveplayerid] = amount;
}
else
{
SendClientMessage(playerid, COLOR_GREY, "That player isn't near you.");
}
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "Invalid player specified.");
}
return 1;
}

Reply
#2

OMG use php dont use quote and which line causing this error?
Reply
#3

Hi!

I did that what you want. Also I optimized your code.

PHP код:
CMD:sellmats(playerid,params[])
{
    if(
Player[playerid][Admin] >= 1)return SendClientMessage(playerid,COLOR_WHITE,"Administrators can't use this command.");
    new 
string[145];
    if(
GetPVarInt(playerid,"SellMatsTimer") > 0)
    {
        
format(string,sizeof string,"You must wait %d seconds before selling more materials.",GetPVarInt(playerid,"SellMatsTimer"));
        
SendClientMessage(playerid,COLOR_WHITE,string);
        return 
1;
    }
    new 
giveplayerid,amount,material[2],price;
    if(
sscanf(params,"us[2]dd",giveplayerid,material,amount,price))return SendClientMessage(playerid,COLOR_WHITE,"USAGE: /sellmats [playerid / partofname] [material] [amount] [price]");
    if(
amount 1)return SendClientMessage(playerid,COLOR_GREY,"Materials amount must be no lower than 1!");
    if(
price 5000)return SendClientMessage(playeridCOLOR_GREY"Price must be no lower than $5000.");
    if(!
strcmp(material,"A",true))if(amount Player[playerid][MatsA])return SendClientMessage(playeridCOLOR_GREY"You don't have that many materials!");
    else if(!
strcmp(material,"B",true))if(amount Player[playerid][MatsB])return SendClientMessage(playeridCOLOR_GREY"You don't have that many materials!");
    else if(!
strcmp(material,"C",true))if(amount Player[playerid][MatsC])return SendClientMessage(playeridCOLOR_GREY"You don't have that many materials!");
    else 
SendClientMessage(playeridCOLOR_GREY"Invalid material class.");
    if(
IsPlayerConnected(giveplayerid))
    {
        if(
giveplayerid != INVALID_PLAYER_ID)
        {
            if(
giveplayerid == playerid)return SendClientMessage(playeridCOLOR_GREY"You can't sell materials to yourself!");
            if(
ProxDetectorS(8.0,playerid,giveplayerid))
            {
                new 
givename[MAX_PLAYER_NAME],myname[MAX_PLAYER_NAME];
                
GetPlayerName(giveplayerid,givename,sizeof(givename));
                
GetPlayerName(playerid,myname,sizeof(myname));
                
format(string,sizeof string,"* You affered %s to buy %d class %s materials for $%d.",givename,amount,material,price);
                
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
                
format(string,sizeof string,"* %s wants to sell you %d class %s materials for $%d. (type /accept mats - to buy)",myname,amount,material,price);
                
SendClientMessage(giveplayerid,COLOR_LIGHTBLUE,string);
                
SetPVarInt(playerid,"SellMatsTimer",30);
                
SetTimerEx("OtherTimerEx",1000,false,"ii",playerid,TYPE_SELLMATSTIMER);
                
MatsOffer[giveplayerid] = playerid;
                
MatsPrice[giveplayerid] = price;
                
MatsType[giveplayerid] = material;
                
MatsAmount[giveplayerid] = amount;
            }
            else return 
SendClientMessage(playeridCOLOR_GREY"That player isn't near you.");
        }
        else return 
SendClientMessage(playeridCOLOR_GREY"Invalid player specified.");
    }
    return 
1;

Reply
#4

Thanks but i got error

error 006: must be assigned to an array

This is the line that the error occurs

Quote:

MatsType[giveplayerid] = material;

Reply
#5

Oh, sorry.

PHP код:
MatsType[giveplayerid] = material
to
PHP код:
format(MatsType[giveplayerid],2,"%s",material); 
And the declaration of MatsType:
PHP код:
new MatsType[MAX_PLAYERS][2]; 
Reply
#6

Hi Mecent, thanks it's fixed already, how about this? can you make work this also?

PHP код:
CMD:accept(playeridparams[])
{
       if(
Player[playerid][Admin] >= 1)
     {
          
SendClientMessage(playerid,COLOR_WHITE"Administrators can't use this command.");
        return 
1;
    }
    new 
string[145];
    
//new sendername[MAX_PLAYER_NAME];
    //new giveplayer[MAX_PLAYER_NAME];
    
new material[2];

    if(
IsPlayerConnected(playerid))
    {
        if(
isnull(params))
        {
            
SendClientMessage(playeridCOLOR_WHITE"USAGE: /accept [name]");
            
SendClientMessage(playeridCOLOR_GREY"Available Names: Mats");
            return 
1;
        }
           else if(
strcmp(params,"mats",true) == 0)
        {
            if(
MatsOffer[playerid] < 999)
            {
                if(
GetPlayerMoney(playerid) >= MatsPrice[playerid])
                {
                    if(
IsPlayerConnected(MatsOffer[playerid]))
                    {
                        if(
GetPVarInt(playerid"SellMatsTimer") > 0)
                        {
                            
format(stringsizeof(string), "You must wait %d seconds before accepting materials."GetPVarInt(playerid"SellMatsTimer"));
                            
SendClientMessage(playerid,COLOR_GREY,string);
                            return 
1;
                        }
                        
                        if (
Player[MatsOffer[playerid]][MatsA] < MatsAmount[playerid])
                        {
                            
SendClientMessage(playerid,COLOR_GREY"That player does not have that amount of materials anymore!");
                            return 
1;
                        }
                        else if (
Player[MatsOffer[playerid]][MatsB] < MatsAmount[playerid])
                        {
                            
SendClientMessage(playerid,COLOR_GREY"That player does not have that amount of materials anymore!");
                            return 
1;
                        }
                        else if (
Player[MatsOffer[playerid]][MatsC] < MatsAmount[playerid])
                        {
                            
SendClientMessage(playerid,COLOR_GREY"That player does not have that amount of materials anymore!");
                            return 
1;
                        }

                         
format(stringsizeof(string), "* You bought %d class %s materials for $%d from %s."MatsAmount[playerid], materialMatsPrice[playerid], GetName(MatsOffer[playerid]));
                        
SendClientMessage(playeridCOLOR_LIGHTBLUEstring);
                          
format(stringsizeof(string), "* %s has bought your %d class %s materials, the $%d was added to your money."GetName(playerid), MatsAmount[playerid], materialMatsPrice[playerid]);
                        
SendClientMessage(MatsOffer[playerid], COLOR_LIGHTBLUEstring);

                          
GivePlayerMoney(MatsOffer[playerid], MatsPrice[playerid]);
                        
GivePlayerMoney(playerid, -MatsPrice[playerid]);
                        
                        if (
strcmp(material"A"true))
                        {
                            
Player[playerid][MatsA] += MatsAmount[playerid];
                            
Player[MatsOffer[playerid]][MatsA] -= MatsAmount[playerid];
                        }
                        else if (
strcmp(material"B"true))
                        {
                            
Player[playerid][MatsB] += MatsAmount[playerid];
                            
Player[MatsOffer[playerid]][MatsB] -= MatsAmount[playerid];
                        }
                        else if (
strcmp(material"C"true))
                        {
                            
Player[playerid][MatsC] += MatsAmount[playerid];
                            
Player[MatsOffer[playerid]][MatsC] -= MatsAmount[playerid];
                        }

                        
MatsOffer[playerid] = 999;
                        
MatsPrice[playerid] = 0;
                         
MatsType[playerid] = 0;
                        
MatsAmount[playerid] = 0;
                    }
                }
                else
                {
                    
SendClientMessage(playeridCOLOR_GREY"You can't afford those materials!");
                    return 
1;
                }
            }
            else
            {
                
SendClientMessage(playeridCOLOR_GREY"No-one offered you any materials!");
                return 
1;
            }
        }
    }
    return 
1;

Reply
#7

Hi Mecent, thanks it's fixed already, how about this? can you make work this also?

PHP код:
CMD:accept(playeridparams[])
{
       if(
Player[playerid][Admin] >= 1)
     {
          
SendClientMessage(playerid,COLOR_WHITE"Administrators can't use this command.");
        return 
1;
    }
    new 
string[145];
    
//new sendername[MAX_PLAYER_NAME];
    //new giveplayer[MAX_PLAYER_NAME];
    
new material[2];
    if(
IsPlayerConnected(playerid))
    {
        if(
isnull(params))
        {
            
SendClientMessage(playeridCOLOR_WHITE"USAGE: /accept [name]");
            
SendClientMessage(playeridCOLOR_GREY"Available Names: Mats");
            return 
1;
        }
           else if(
strcmp(params,"mats",true) == 0)
        {
            if(
MatsOffer[playerid] < 999)
            {
                if(
GetPlayerMoney(playerid) >= MatsPrice[playerid])
                {
                    if(
IsPlayerConnected(MatsOffer[playerid]))
                    {
                        if(
GetPVarInt(playerid"SellMatsTimer") > 0)
                        {
                            
format(stringsizeof(string), "You must wait %d seconds before accepting materials."GetPVarInt(playerid"SellMatsTimer"));
                            
SendClientMessage(playerid,COLOR_GREY,string);
                            return 
1;
                        }
                        
                        if (
Player[MatsOffer[playerid]][MatsA] < MatsAmount[playerid])
                        {
                            
SendClientMessage(playerid,COLOR_GREY"That player does not have that amount of materials anymore!");
                            return 
1;
                        }
                        else if (
Player[MatsOffer[playerid]][MatsB] < MatsAmount[playerid])
                        {
                            
SendClientMessage(playerid,COLOR_GREY"That player does not have that amount of materials anymore!");
                            return 
1;
                        }
                        else if (
Player[MatsOffer[playerid]][MatsC] < MatsAmount[playerid])
                        {
                            
SendClientMessage(playerid,COLOR_GREY"That player does not have that amount of materials anymore!");
                            return 
1;
                        }
                         
format(stringsizeof(string), "* You bought %d class %s materials for $%d from %s."MatsAmount[playerid], materialMatsPrice[playerid], GetName(MatsOffer[playerid]));
                        
SendClientMessage(playeridCOLOR_LIGHTBLUEstring);
                          
format(stringsizeof(string), "* %s has bought your %d class %s materials, the $%d was added to your money."GetName(playerid), MatsAmount[playerid], materialMatsPrice[playerid]);
                        
SendClientMessage(MatsOffer[playerid], COLOR_LIGHTBLUEstring);
                          
GivePlayerMoney(MatsOffer[playerid], MatsPrice[playerid]);
                        
GivePlayerMoney(playerid, -MatsPrice[playerid]);
                        
                        if (
strcmp(material"A"true))
                        {
                            
Player[playerid][MatsA] += MatsAmount[playerid];
                            
Player[MatsOffer[playerid]][MatsA] -= MatsAmount[playerid];
                        }
                        else if (
strcmp(material"B"true))
                        {
                            
Player[playerid][MatsB] += MatsAmount[playerid];
                            
Player[MatsOffer[playerid]][MatsB] -= MatsAmount[playerid];
                        }
                        else if (
strcmp(material"C"true))
                        {
                            
Player[playerid][MatsC] += MatsAmount[playerid];
                            
Player[MatsOffer[playerid]][MatsC] -= MatsAmount[playerid];
                        }
                        
MatsOffer[playerid] = 999;
                        
MatsPrice[playerid] = 0;
                         
MatsType[playerid] = 0;
                        
MatsAmount[playerid] = 0;
                    }
                }
                else
                {
                    
SendClientMessage(playeridCOLOR_GREY"You can't afford those materials!");
                    return 
1;
                }
            }
            else
            {
                
SendClientMessage(playeridCOLOR_GREY"No-one offered you any materials!");
                return 
1;
            }
        }
    }
    return 
1;

Reply
#8

Bump?
Reply
#9

Sorry for my lateness.
PHP код:
CMD:sellmats(playerid,params[])
{
    if(
Player[playerid][Admin] >= 1)return SendClientMessage(playerid,COLOR_WHITE,"Administrators can't use this command.");
    new 
string[145];
    if(
GetPVarInt(playerid,"SellMatsTimer") > 0)
    {
        
format(string,sizeof string,"You must wait %d seconds before selling more materials.",GetPVarInt(playerid,"SellMatsTimer"));
        
SendClientMessage(playerid,COLOR_WHITE,string);
        return 
1;
    }
    new 
giveplayerid,amount,material[2],price;
    if(
sscanf(params,"us[2]dd",giveplayerid,material,amount,price))return SendClientMessage(playerid,COLOR_WHITE,"USAGE: /sellmats [playerid / partofname] [material] [amount] [price]");
    if(
amount 1)return SendClientMessage(playerid,COLOR_GREY,"Materials amount must be no lower than 1!");
    if(
price 5000)return SendClientMessage(playeridCOLOR_GREY"Price must be no lower than $5000.");
    if(!
strcmp(material,"A",true))if(amount Player[playerid][MatsA])return SendClientMessage(playeridCOLOR_GREY"You don't have that many materials!");
    else if(!
strcmp(material,"B",true))if(amount Player[playerid][MatsB])return SendClientMessage(playeridCOLOR_GREY"You don't have that many materials!");
    else if(!
strcmp(material,"C",true))if(amount Player[playerid][MatsC])return SendClientMessage(playeridCOLOR_GREY"You don't have that many materials!");
    else 
SendClientMessage(playeridCOLOR_GREY"Invalid material class.");
    if(
IsPlayerConnected(giveplayerid))
    {
        if(
giveplayerid != INVALID_PLAYER_ID)
        {
            if(
giveplayerid == playerid)return SendClientMessage(playeridCOLOR_GREY"You can't sell materials to yourself!");
            if(
ProxDetectorS(8.0,playerid,giveplayerid))
            {
                new 
givename[MAX_PLAYER_NAME],myname[MAX_PLAYER_NAME];
                
GetPlayerName(giveplayerid,givename,sizeof(givename));
                
GetPlayerName(playerid,myname,sizeof(myname));
                
format(string,sizeof string,"* You affered %s to buy %d class %s materials for $%d.",givename,amount,material,price);
                
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
                
format(string,sizeof string,"* %s wants to sell you %d class %s materials for $%d. (type /accept mats - to buy)",myname,amount,material,price);
                
SendClientMessage(giveplayerid,COLOR_LIGHTBLUE,string);
                
SetPVarInt(playerid,"SellMatsTimer",30);
                
SetTimerEx("OtherTimerEx",1000,false,"ii",playerid,TYPE_SELLMATSTIMER);
                
MatsOffer[giveplayerid] = playerid;
                
MatsPrice[giveplayerid] = price;
                
format(MatsType[giveplayerid],2,"%s",material);
                
MatsAmount[giveplayerid] = amount;
            }
            else return 
SendClientMessage(playeridCOLOR_GREY"That player isn't near you.");
        }
        else return 
SendClientMessage(playeridCOLOR_GREY"Invalid player specified.");
    }
    return 
1;
}
CMD:accept(playerid,params[])
{
    if(
Player[playerid][Admin] >= 1)return SendClientMessage(playerid,COLOR_WHITE"Administrators can't use this command.");
    new 
string[145];
    if(
isnull(params))
    {
        
SendClientMessage(playerid,COLOR_WHITE,"USAGE: /accept [name]");
        
SendClientMessage(playerid,COLOR_GREY,"Available Names: Mats");
        return 
1;
    }
    if(!
strcmp(params,"mats",true))
    {
        if(
MatsOffer[playerid] == 999)return SendClientMessage(playeridCOLOR_GREY"No-one offered you any materials!");
        if(
GetPlayerMoney(playerid) < MatsPrice[playerid])return SendClientMessage(playeridCOLOR_GREY"You can't afford those materials!");
        if(
IsPlayerConnected(MatsOffer[playerid]))
        {
            if(
GetPVarInt(playerid,"SellMatsTimer") > 0)
            {
                
format(string,sizeof string,"You must wait %d seconds before accepting materials.",GetPVarInt(playerid,"SellMatsTimer"));
                
SendClientMessage(playerid,COLOR_GREY,string);
                return 
1;
            }
            if(
Player[MatsOffer[playerid]][MatsA] < MatsAmount[playerid])
            {
                
SendClientMessage(playerid,COLOR_GREY"That player does not have that amount of materials anymore!");
                 return 
1;
            }
            else if(
Player[MatsOffer[playerid]][MatsB] < MatsAmount[playerid]))
            {
                
SendClientMessage(playerid,COLOR_GREY"That player does not have that amount of materials anymore!");
                 return 
1;
            }
            else if(
Player[MatsOffer[playerid]][MatsC] < MatsAmount[playerid]))
            {
                
SendClientMessage(playerid,COLOR_GREY"That player does not have that amount of materials anymore!");
                 return 
1;
            }
            
format(stringsizeof(string), "* You bought %d class %s materials for $%d from %s."MatsAmount[playerid], MatsType[playerid], MatsPrice[playerid], GetName(MatsOffer[playerid]));
             
SendClientMessage(playeridCOLOR_LIGHTBLUEstring);
              
format(stringsizeof(string), "* %s has bought your %d class %s materials, the $%d was added to your money."GetName(playerid), MatsAmount[playerid], MatsType[playerid], MatsPrice[playerid]);
               
SendClientMessage(MatsOffer[playerid], COLOR_LIGHTBLUEstring);
               
GivePlayerMoney(MatsOffer[playerid], MatsPrice[playerid]);
            
GivePlayerMoney(playerid, -MatsPrice[playerid]);
            if(!
strcmp(MatsType[playerid],"A",true))
            {
                
Player[playerid][MatsA] += MatsAmount[playerid];
                
Player[MatsOffer[playerid]][MatsA] -= MatsAmount[playerid];
            }
            else if(!
strcmp(MatsType[playerid],"B",true))
            {
                
Player[playerid][MatsB] += MatsAmount[playerid];
                
Player[MatsOffer[playerid]][MatsB] -= MatsAmount[playerid];
            }
            else if(!
strcmp(MatsType[playerid],"C",true))
            {
                
Player[playerid][MatsC] += MatsAmount[playerid];
                
Player[MatsOffer[playerid]][MatsC] -= MatsAmount[playerid];
            }
            
MatsOffer[playerid] = 999;
            
MatsPrice[playerid] = 0;
               
format(MatsType[playerid],2,"");
               
MatsAmount[playerid] = 0;
        }
    }
    return 
1;

MatsType has to be a string with the length of 2.
Reply
#10

Thanks for the fix mecent, i have now another problem

If i sell the mats, then the other player accepts it, it shows this message, even i have enough materials.

PHP код:
That player does not have that amount of materials anymore
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)