[HELP]Car System!!!
#8

So,here's the last code I managed to write ,there are no errors when compiling,but there is a problem:

pawn Код:
#define MAX_CARS 200

new CarInfo[MAX_CARS][carinfo];
new CarCount = -1;

stock AddBuyableVehicle(Name[],Cost,Float:vx,Float:vy,Float:vz,CarModel)
{
    new playerid;
    new string[64];
    if(!dini_Exists("Owners.ini"))
    {
        dini_Create("Owners.ini");
    }
    CarCount ++;
    new ID = CarCount;
    CarInfo[ID][CarPrice] = Cost;
    CarInfo[ID][vX] = vx;
    CarInfo[ID][vY] = vy;
    CarInfo[ID][vZ] = vz;
    CarInfo[ID][Model] = CarModel;
    format(Name,strlen(Name) + 10,Name[GetVehicleModel(GetPlayerVehicleID(playerid))-400],Name);
    if(strlen(dini_Get("Owners.ini", string)))
    {
    format(string,sizeof(string),"/Accounts/Owners.ini",CarInfo[ID][CarOwner]);
    CarInfo[ID][Owned] = 1;
    }
    dini_Create(string);
    dini_Set(string,"Info:CarInfo[ID][CarOwner]-CarInfo[ID][Model]-Name",CarInfo[ID][CarOwner]);
    CarInfo[ID][ForSell] = 1;
    CreateVehicle(CarModel,vx,vy,vz,45,0,0,0);
}

stock GetCarID(vehicleid)
{
    for(new i=0;i < sizeof(CarInfo);i++)
    {
        if(CarInfo[i][Model] == vehicleid)
        {
            return i;
        }
    }
    return 0;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
        new vehicleid=GetPlayerVehicleID(playerid);
    new ID = GetCarID(vehicleid);
    new string[120];
    new Name[120];
    format(string,sizeof(string),"/Accounts/Owners.ini",CarInfo[ID][CarOwner]);
    format(Name,strlen(Name) + 10,Name[GetVehicleModel(GetPlayerVehicleID(playerid))-400],Name);
    for(new i;i<MAX_CARS;i++)
    {
      new cstring[120];
      format(cstring,sizeof(cstring),"This car is for sell.Price:%d$",CarInfo[ID][CarPrice]);
      if(newstate == PLAYER_STATE_DRIVER && CarInfo[ID][ForSell] == 1) return ShowPlayerDialog(playerid,DIALOG_CFS,DIALOG_STYLE_MSGBOX,"CarInfo",cstring,"Accept","Cancel") && TogglePlayerControllable(playerid,true);
    }
    if(!strcmp(CarInfo[ID][CarOwner],dini_Get(string,"Info:CarInfo[ID][CarOwner]-CarInfo[ID][Model]-Name"),false))
    {
        new ystring[120];
        format(ystring,sizeof(ystring),"Welcome to your own '%s'",Name);
        GameTextForPlayer(playerid,ystring,2500,4);
        return 1;
    }
    else
    {
        new Float:x,Float:y,Float:z;
        new ostring[120];
        format(ostring,sizeof(ostring),"This car is owned by:%s",CarInfo[ID][CarOwner]);
        GameTextForPlayer(playerid,ostring,2500,4);
        SetPlayerPos(playerid,x,y,z + 3);
        return 1;
    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new Float:x,Float:y,Float:z;
    new vehicleid=GetPlayerVehicleID(playerid);
    new ID = GetCarID(vehicleid);
    new bv;
    if(dialogid==DIALOG_CFS)
    {
       if(response==0)  return 1;
       if((response==1) && GetPlayerMoney(playerid) < CarInfo[ID][CarPrice]) return SendClientMessage(playerid,COLOR_RED,"You don't have enough money to buy this car") && SetPlayerPos(playerid,x,y,z + 3);
       else if((response==1) && GetPlayerMoney(playerid) >= CarInfo[ID][CarPrice])
       {
         bv = CreateVehicle(GetVehicleModel(GetPlayerVehicleID(playerid)),-1997.3328,290.0271,34.0448,0,0,0,0);
         PutPlayerInVehicle(playerid,bv,1);
         CarInfo[ID][Owned] = 1;
         GivePlayerMoney(playerid,-CarInfo[ID][CarPrice]);
         return 1;
       }
    }
  return 1;
}
Now the problem is,that the buying dialog shows to some vehicles,but to others it doesn't,so I suposse the error is here:

pawn Код:
format(Name,strlen(Name) + 10,Name[GetVehicleModel(GetPlayerVehicleID(playerid))-400],Name);
better said it's at "-400" I think,and if I put "-611" then it doesn't show for any vehilce.

Please help me you don't know how I feel,it's like a step from finishing this system,but that last step I can't do it
Reply


Messages In This Thread
[HELP]Car System!!! - by Cjgogo - 24.07.2011, 08:34
Respuesta: [HELP]Car System!!! - by Pepot - 24.07.2011, 08:51
Re: [HELP]Car System!!! - by Cjgogo - 24.07.2011, 09:14
Re: [HELP]Car System!!! - by MadeMan - 24.07.2011, 12:32
Re: [HELP]Car System!!! - by Cjgogo - 24.07.2011, 13:21
Re: [HELP]Car System!!! - by MadeMan - 24.07.2011, 13:25
Re: [HELP]Car System!!! - by Cjgogo - 24.07.2011, 13:27
Re: [HELP]Car System!!! - by Cjgogo - 24.07.2011, 14:07
Re: [HELP]Car System!!! - by Cjgogo - 25.07.2011, 08:55
Re: [HELP]Car System!!! - by Cjgogo - 25.07.2011, 14:25

Forum Jump:


Users browsing this thread: 2 Guest(s)