reading from file
#1

hey guys I tried to make something like this:
PHP код:
stock checkprice(vehicleid)
{
    new 
string[256];
    
format(string, sizeof(string),"%d", dini_Get("vprices.cfg",vehicleid));
    return 
string;
} 
PHP код:
            else if(!strcmp(x_v, "setprice",true))
            {
                if(
IsPlayerConnected(playerid))
                {
                    if(
PlayerInfo[playerid][pAdmi] >= 5000)
                    {
                        if (
PlayerToPoint(50, playerid,SBizzInfo[12][sbEntranceX],SBizzInfo[12][sbEntranceY],SBizzInfo[12][sbEntranceZ]))
                        {
                            
tmp = strtok(cmdtext, idx);
                              if(!
strlen(tmp))
                              {
                                
SendClientMessage(playerid,COLOR_WHITE,"[USAGE]: /setprice [vehiclemodel] [price]");
                                return 
1;
                            }
                            new 
car;
                            new 
price;
                            
car = strval(tmp);
                            
price = strval(tmp);
                            
dini_IntSet("vprices.cfg",car,price);
                            
format(string, sizeof(string), "You have set %s's price to $%d ", VehicleNames[car-400],price);
                            
SendClientMessage(giveplayerid, COLOR_WHITE, string);
                        }
                        else
                        {
                            
SendClientMessage(playerid, COLOR_LIGHTRED, "You are not at a dealership !");
                            return 
1;
                        }
                    }
                }
                return 
1;
            }
            else if(!
strcmp(x_v, "sellcar",true))
            {
                if(
IsPlayerConnected(playerid))
                {
                    if(
PlayerInfo[playerid][pAdmi] >= 5000)
                    {
                        if (
PlayerToPoint(50, playerid,SBizzInfo[12][sbEntranceX],SBizzInfo[12][sbEntranceY],SBizzInfo[12][sbEntranceZ]))
                        {
                            
tmp = strtok(cmdtext, idx);
                              if(!
strlen(tmp))
                              {
                                
SendClientMessage(playerid,COLOR_WHITE,"[USAGE]: /sellcar [vehiclemodel] [Player's id]");
                                return 
1;
                            }
                            new 
car = strval(tmp);
                            new 
price[MAX_STRING];
                            if(
car < 400 || car > 611) { SendClientMessage(playerid, COLOR_GREY, "    Vehicle Number can't be below 400 or above 611!"); return 1; }
                            
tmp = strtok(cmdtext, idx);
                            
giveplayerid = ReturnUser(tmp);
                            if(
IsPlayerConnected(giveplayerid))
                            {
                                if(
giveplayerid != INVALID_PLAYER_ID)
                                {
                                    if(
CarsPrices[car-400] == 0)
                                    {
                                        
SendClientMessage(playerid, COLOR_GREY, "    You are not able to sell this vehicle!");
                                        return 
1;
                                    }
                                    
/*if(HMoney[playerid] < CarsPrices[car-400])
                                    {
                                        SendClientMessage(playerid, COLOR_YELLOW2, "    You haven't enough money !");
                                        return 1;
                                    }*/
                                    //new file[256];
                                    //format(file, sizeof(file), "Vehicles/vprice.cfg");
                                    
price = checkprice(car);
                                    
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                                     
GetPlayerName(playerid, sendername, sizeof(sendername));
                                    if(!
CheckCarF(playerid,car))
                                    {
                                        if(
price != 0)
                                        {
                                            
pCar[giveplayerid] = car;
                                            
pCarPrice[giveplayerid] = price;
                                            
pColorS[giveplayerid] = 1;
                                            
pColor2S[giveplayerid] = 1;
                                            
format(string, sizeof(string), "%s offers to %s %s for $%d", sendername,giveplayer,VehicleNames[car-400],checkprice(car));
                                            
ProxDetector(20.0, playerid, string, COLOR_NICEBLUE,COLOR_NICEBLUE,COLOR_NICEBLUE,COLOR_NICEBLUE,COLOR_NICEBLUE);
                                            
format(string, sizeof(string), "%s offered you %s for $%d", sendername,VehicleNames[car-400],checkprice(car));
                                            
SendClientMessage(giveplayerid, COLOR_WHITE, string);
                                            
SendClientMessage(giveplayerid, COLOR_WHITE, "type /acceptcar if you want to buy or /cancelcar if you dont want to but it");
                                             
//BuyingVeh(playerid);
                                        
}
                                        else
                                        {
                                            
SendClientMessage(playerid,COLOR_WHITE,"The leader didn't ordered this vehicle!");
                                        }
                                    }
                                    else
                                    {
                                        
SendClientMessage(playerid,COLOR_WHITE,"That player already has this vehicle!");
                                    }
                                }
                            }
                            else
                            {
                                
format(string, sizeof(string), "   %d is not an active player.", giveplayerid);
                                
SendClientMessage(playerid, COLOR_GRAD1, string);
                            }
                        }
                        else
                        {
                            
SendClientMessage(playerid, COLOR_LIGHTRED, "You are not at a dealership !");
                            return 
1;
                        }
                    }
                }
                return 
1;
            } 
the errors is this:
PHP код:
cuments and Settings\Vlad\щемзп дтбегд\LS-Mode2.pwn(45527) : error 035: argument type mismatch (argument 2)
C:\Documents and Settings\Vlad\щемзп дтбегд\LS-Mode2.pwn(45575) : error 047: array sizes do not match, or destination array is too small
C
:\Documents and Settings\Vlad\щемзп дтбегд\LS-Mode2.pwn(45580) : error 033: array must be indexed (variable "price")
C:\Documents and Settings\Vlad\щемзп дтбегд\LS-Mode2.pwn(45583) : error 006: must be assigned to an array
C:\Documents and Settings\Vlad\щемзп дтбегд\LS-Mode2.pwn(45753) : error 006: must be assigned to an array
C:\Documents and Settings\Vlad\щемзп дтбегд\LS-Mode2.pwn(55968) : error 035: argument type mismatch (argument 2)
C:\Documents and Settings\Vlad\щемзп дтбегд\LS-Mode2.pwn(55950) : warning 203: symbol is never used: "vehicleid"
Pawn compiler 3.2.3664              Copyright (c) 1997-2006, ITB CompuPhase
6 Errors
. 
error 1:
PHP код:
dini_IntSet("vprices.cfg",car,price); 
error 2:
PHP код:
price = checkprice(car); 
error 3:
PHP код:
if(price != 0) 
error 4:
PHP код:
pCarPrice[giveplayerid] = price; 
error 5:
PHP код:
plaprice = file; 
error 6:
format(string, sizeof(string),"%d", dini_Get("vprices.cfg",vehicleid));
error:7
canno't read the vehicle id

the file is like this:
http://pastebin.com/U8KZm4Av
help me please
Reply
#2

for the price error, you might wanna use "strval(price)"
Try replacing those.
Reply
#3

Use ZCMD, it's much easier to use, plus you won't have bug with that.
And use sscanf with the zCMD, this way:
PHP код:
    if ( sscanf( params, "ii", params[ 0 ], params[ 1 ]) )
        return 
SendClientMessage( playerid, COLOR_WHITE, "[USAGE]: /setprice [vehiclemodel] [price]"); 
then do the same thing under it
Reply
#4

Quote:
Originally Posted by yanir3
Посмотреть сообщение
Use ZCMD, it's much easier to use, plus you won't have bug with that.
And use sscanf with the zCMD, this way:
PHP код:
    if ( sscanf( params, "ii", params[ 0 ], params[ 1 ]) )
        return 
SendClientMessage( playerid, COLOR_WHITE, "[USAGE]: /setprice [vehiclemodel] [price]"); 
then do the same thing under it
can you do this for me?
Reply
#5

PHP код:
CMD:setprice( playerid, params[ ] )
{
    if ( 
sscanf( params, "ii", params[ 0 ], params[ 1 ]) )
        return 
SendClientMessage( playerid, COLOR_WHITE, "[USAGE]: /setprice [vehiclemodel] [price]");  
                if(
IsPlayerConnected(playerid))
                {
                    if(
PlayerInfo[playerid][pAdmi] >= 5000)
                    {
                        if (
PlayerToPoint(50, playerid,SBizzInfo[12][sbEntranceX],SBizzInfo[12][sbEntranceY],SBizzInfo[12][sbEntranceZ]))
                        {
                            
dini_IntSet("vprices.cfg",params[0],params[1]);
                            
format(string, sizeof(string), "You have set %s's price to $%d ", VehicleNames[params[0]-400],params[1]);
                            
SendClientMessage(giveplayerid, COLOR_WHITE, string);
                        }
                        else
                        {
                            
SendClientMessage(playerid, COLOR_LIGHTRED, "You are not at a dealership !");
                            return 
1;
                        }
                    }
                } 
    return 
1;
} 
Simple as that.
Reply
#6

PHP код:
C:\Documents and Settings\Vlad\щемзп дтбегд\LS-Mode2.pwn(45432) : error 017: undefined symbol "setprice"
C:\Documents and Settings\Vlad\щемзп дтбегд\LS-Mode2.pwn(45434) : error 017: undefined symbol "params"
C:\Documents and Settings\Vlad\щемзп дтбегд\LS-Mode2.pwn(45434) : warning 215: expression has no effect
C
:\Documents and Settings\Vlad\щемзп дтбегд\LS-Mode2.pwn(45434) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\Vlad\щемзп дтбегд\LS-Mode2.pwn(45434) : error 029: invalid expression, assumed zero
C
:\Documents and Settings\Vlad\щемзп дтбегд\LS-Mode2.pwn(45434) : fatal error 107: too many error messages on one line 
what to do?
Reply
#7

#include < ZCMD >
#include < sscanf2 >

Delete the sscanf stock you have on your script.
And load the sscanf plugin.
Reply
#8

still have the other errors look at this
PHP код:
C:\Documents and Settings\Vlad\щемзп дтбегд\LS-Mode2.pwn(45600) : error 047: array sizes do not match, or destination array is too small
C
:\Documents and Settings\Vlad\щемзп дтбегд\LS-Mode2.pwn(45605) : error 033: array must be indexed (variable "price")
C:\Documents and Settings\Vlad\щемзп дтбегд\LS-Mode2.pwn(45608) : error 006: must be assigned to an array
C:\Documents and Settings\Vlad\щемзп дтбегд\LS-Mode2.pwn(45778) : error 006: must be assigned to an array
C:\Documents and Settings\Vlad\щемзп дтбегд\LS-Mode2.pwn(55768) : warning 213: tag mismatch
C
:\Documents and Settings\Vlad\щемзп дтбегд\LS-Mode2.pwn(55978) : error 035: argument type mismatch (argument 2)
C:\Documents and Settings\Vlad\щемзп дтбегд\LS-Mode2.pwn(55975) : warning 203: symbol is never used: "vehicleid" 
line 45600:
PHP код:
price = checkprice(car); 
Reply
#9

Convert it to zCMD.
Reply
#10

I have fixed all errors exept this:
PHP код:
error 035: argument type mismatch (argument 2) 
I have this error in three places
here:
PHP код:
            else if(!strcmp(x_v, "getprice",true))
            {
                if(
IsPlayerConnected(playerid))
                {
                    if(
PlayerInfo[playerid][pAdmi] >= 5000)
                    {
                        
tmp = strtok(cmdtext, idx);
                          if(!
strlen(tmp))
                          {
                            
SendClientMessage(playerid,COLOR_WHITE,"[USAGE]: /getprice [vehiclemodel]");
                            return 
1;
                        }
                        new 
car = strval(tmp);
                        
//new file[256];
                        //format(file, sizeof(file), "Vehicles/vprice.cfg");
                        //new price[MAX_STRING];
                        //price = dini_Get(file,car);
                        
format(string, sizeof(string), "%s's price is $%d ", VehicleNames[car-400],dini_Int("vprices.cfg",car));// the error here
                        
SendClientMessage(giveplayerid, COLOR_WHITE, string);
                    }
                }
                return 
1;
            } 
and here:
PHP код:
new PriceS = (dini_Int("vprices.cfg",plaveh)*20)/100;
new 
Price = dini_Int("vprices.cfg",plaveh)-PriceS; 
help me please!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)