SA-MP Forums Archive
veh file save! [Mrki_Drakula] (rep+) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: veh file save! [Mrki_Drakula] (rep+) (/showthread.php?tid=304756)



Veh file save! + Kill/Death Ratio (rep+) - Ballu Miaa - 19.12.2011

First-
A guy Called Mrki_Drakula gave me this code to Load Vehicle's from a file! But i dont know the usage or anything about using this FS he has designed. Can someone please tell me what each function is doing over here and How to Load and Save Vehicle's using LoadStaticVehicleFromFile() , Help will be highly appreciated with rep+

Thanks
Ballu Miaa

pawn Код:
#include <a_samp>
#include <gl_common>

#define FILTERSCRIPT
#define CARS "cars.ini"

new bool:ValidVeh[MAX_VEHICLES] ;

public OnFilterScriptInit()
{
   LoadStaticVehiclesFromFile(CARS);
   return 1;
}

public OnFilterScriptExit()
{
    new fstring[288], Float:vX, Float:vY, Float:vZ, Float:vA, File:veh;
    for(new v = 0; v < MAX_VEHICLES; v++)
    {
        if(!ValidVeh[v]) return 0;
        GetVehiclePos(v, vX, vY, vZ); GetVehicleZAngle(v, vA);
        format(fstring, 288, "%d, %f, %f, %f, %f, -1, -1, -1;\r\n", GetVehicleModel(v), vX, vY, vZ, vA);
        veh = fopen(CARS, io_append);
        fwrite(veh, fstring);
        fclose(veh);
    }
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    ValidVeh[vehicleid] = true;
    return 1;
}

public OnVehicleDeath(vehicleid)
{
    ValidVeh[vehicleid] = false;
    return 1;
}



Re: veh file save! [Mrki_Drakula] (rep+) - Ballu Miaa - 19.12.2011

Second-
I want to show Kills/Deaths ratio of a player on their /Stats.
This is the PlayerInfo[playerid][pKills] & PlayerInfo[playerid][pDeaths] on pInfo enum!
Please tell me what to do to create this?


Re: veh file save! [Mrki_Drakula] (rep+) - Norck - 19.12.2011

For your second question, put this in your command:
pawn Код:
new str[128];
if(PlayerInfo[playerid][pDeaths] != 0)  // to avoid division by zero
{
    format(str,sizeof(str),"Your KpD ratio: %.3f",PlayerInfo[playerid][pKills]/PlayerInfo[playerid][pDeaths]);
    SendClientMessage(playerid,-1,str);
}
else
    SendClientMessage(playerid,-1,"You haven't died yet!");



Re: veh file save! [Mrki_Drakula] (rep+) - Ballu Miaa - 20.12.2011

Allright Thanks for it Norck! But i need for first post as well