A problem
#1

Hi. I have a problem with my rp script. I have a simple car-ownership, and I'm creating cars into a file, named cars.cfg and the script loads them but I can't use the car cmds, because the carkey is still 999 (nule).

I have tried this way:
pawn Код:
new playername[MAX_PLAYER_NAME];
      GetPlayerName(playerid, playername, sizeof(playername));
      if(strcmp(playername, CarInfo[PlayerInfo[playerid][pPcarkey]][cOwner], true) == 0)
      {
      ....
But I get the error: SERVER: Unknown command, why?
Reply
#2

maybe like this?
Код:
if(strcmp(playername,CarInfo[PlayerInfo[playerid][pPcarkey]][cOwner],true,getlength(playername)==0)
Reply
#3

Nope, doesen't works..

I'd explain better. So, I have a simple car ownership and the cars are loading from cars.cfg. I haven't any /buycar cmd, and the carkey is still 999, I want to know if it's possible to set the carkey to the player if it's online to his personal car.. here's my script:
pawn Код:
enum cInfo
{
    cModel,
    Float:cLocationx,
    Float:cLocationy,
    Float:cLocationz,
    Float:cAngle,
    cColorOne,
    cColorTwo,
    cOwner[MAX_PLAYER_NAME],
    cDescription[MAX_PLAYER_NAME],
    cValue,
    cLicense,
    cOwned,
    cLock,
};

new CarInfo[66][cInfo];
pawn Код:
public LoadCar()
{
    new arrCoords[13][64];
    new strFromFile2[256];
    new File: file = fopen("cars.cfg", io_read);
    if (file)
    {
        new idx = 1;
        while (idx < sizeof(CarInfo))
        {
            fread(file, strFromFile2);
            split(strFromFile2, arrCoords, ',');
            CarInfo[idx][cModel] = strval(arrCoords[0]);
            CarInfo[idx][cLocationx] = floatstr(arrCoords[1]);
            CarInfo[idx][cLocationy] = floatstr(arrCoords[2]);
            CarInfo[idx][cLocationz] = floatstr(arrCoords[3]);
            CarInfo[idx][cAngle] = floatstr(arrCoords[4]);
            CarInfo[idx][cColorOne] = strval(arrCoords[5]);
            CarInfo[idx][cColorTwo] = strval(arrCoords[6]);
            strmid(CarInfo[idx][cOwner], arrCoords[7], 0, strlen(arrCoords[7]), 255);
            strmid(CarInfo[idx][cDescription], arrCoords[8], 0, strlen(arrCoords[8]), 255);
            CarInfo[idx][cValue] = strval(arrCoords[9]);
            CarInfo[idx][cLicense] = strval(arrCoords[10]);
            CarInfo[idx][cOwned] = strval(arrCoords[11]);
            CarInfo[idx][cLock] = strval(arrCoords[12]);
            printf("CarInfo: %d Owner:%s Owned: %d Locked: %d",idx,CarInfo[idx][cOwner],CarInfo[idx][cOwned],CarInfo[idx][cLock]);
            idx++;
        }
    }
    return 1;
}

public SaveCarCoords()
{
    new idx;
    new File: file2;
    while (idx < sizeof(CarInfo))
    {
      new coordsstring[256];
      format(coordsstring, sizeof(coordsstring), "%d|%f|%f|%f|%f|%d|%d\n",
        CarInfo[idx][cModel],
        CarInfo[idx][cLocationx],
        CarInfo[idx][cLocationy],
        CarInfo[idx][cLocationz],
        CarInfo[idx][cAngle],
        CarInfo[idx][cColorOne],
        CarInfo[idx][cColorTwo]);
        if(idx == 0)
        {
            file2 = fopen("cars.cfg", io_write);
        }
        else
        {
            file2 = fopen("cars.cfg", io_append);
        }
        fwrite(file2, coordsstring);
        idx++;
        fclose(file2);
    }
    return 1;
}
And in the OnGameModeInit I have LoadCar(); which loades the cars. Please help ..
Reply
#4

Solved now, but I want to save the CarLicense in a 3dtextlabel, when I set it, it works but when i restart the server it doesen't save..
Reply
#5

Bump?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)