[HELP] X,Y,Z positions writing
#1

Hello , I'm making a new /buyvehicle command , so anyway it should work like this :
when someone is ia the delevership he types /buyvehicle [name] ( only BMX code should work for now ) and it adds a car into /cfg/cars.cfg and spawns it
The line should look like this :
pawn Код:
ModelID,x,y,z,0.0,color1,color2,PlayerName,BMX,PriceForSale,,0,0
I have made that color1 and color2 are automatic 0 , and players will be able to change them after
Anyway , so here's the problem , when i make it all it should write line like that , but it writes line like this :
pawn Код:
481,[bmx,п[bmx,Mп[bmx,0.0,0,0,Ivan_Pantovic,BMX,20000,,1,0
Here's the code , please help me

pawn Код:
forward VehicleBuy(string[]);
pawn Код:
public VehicleBuy(string[])
{
    new entry[256];
    format(entry, sizeof(entry), "%s\n",string);
    new File:hFile;
    hFile = fopen("cfg/cars.cfg", io_append);
    fwrite(hFile, entry);
    fclose(hFile);
}
pawn Код:
if(!strcmp(cmd, "/buyvehicle", true))
    {
      if(IsAtDealership(playerid))
    {
        new x_nr[256];
            x_nr = strtok(cmdtext, idx);
            if(!strlen(x_nr))
            {
            SendClientMessage(playerid, COLOR_RED, "_____________Vehicles_____________");
            SendClientMessage(playerid, COLOR_ORANGE, "Bikes : BMX (20000$)") ;
            SendClientMessage(playerid, COLOR_ORANGE, "Moto-Bikes : ");
            SendClientMessage(playerid, COLOR_ORANGE, "Cars : Buffalo (500000$)");
        SendClientMessage(playerid, COLOR_RED, "_____________Vehicles_____________");
                SendClientMessage(playerid, COLOR_GREEN, "HINT: /buyvehicle [name]");
            return 1;
            }
        if(strcmp(x_nr,"bmx",true) == 0)
                {
                SendClientMessage(playerid, COLOR_WHITE, "You bought BMX for 20000$ !");
        SafeGivePlayerMoney(playerid,- 20000);
                new Float:x,Float:y,Float:z;
                GetPlayerPos(playerid, Float:x, Float:y, Float:z);
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "481,%s,%s,%s,0.0,0,0,%s,BMX,20000,,1,0", Float:x, Float:y, Float:z, sendername);
                VehicleBuy(string);
                }
        else if(strcmp(x_nr,"buffalo",true) == 0)
                {
                SendClientMessage(playerid, COLOR_WHITE, "You bought Buffalo for 500000$ !");
                }
            else
                {
                SendClientMessage(playerid, COLOR_RED, "_____________Vehicles_____________");
            SendClientMessage(playerid, COLOR_ORANGE, "Bikes : BMX (20000$)");
            SendClientMessage(playerid, COLOR_ORANGE, "Moto-Bikes : ");
            SendClientMessage(playerid, COLOR_ORANGE, "Cars : Buffalo (500000$)");
            SendClientMessage(playerid, COLOR_RED, "_____________Vehicles_____________");
                    SendClientMessage(playerid, COLOR_GREEN, "HINT: /buyvehicle [name]");
                    return 1;
                }
        return 1;
        }
        else
        {
        SendClientMessage(playerid, COLOR_RED, "You are not at the dealership !");
        }
    }
Reply
#2

Can anyone help please :S ?
Reply
#3

pawn Код:
format(string, sizeof(string), "481,%f,%f,%f,0.0,0,0,%s,BMX,20000,,1,0", x, y, z, sendername);
since x, y and z are floats.

And you don't need to use Float in functions, just when declaring the variables

pawn Код:
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
This will also work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)