20.04.2013, 06:48
Hi, i edited Vehicle Ownership (players) to Teams.
Variables:
vcreate cmd:
And loading...
Now, i added a car to my team (team4). Car saving is good, the vOwner variable sets to 4.
I added a simple debug
When i'm trying to get into my team veh i got BAD, when i try to get into other team vehicle i got BAD, wtf?
Variables:
pawn Код:
enum _VINFO
{
vModel,
vColor1,
vColor2,
vOwner,
Float:vPosX,
Float:vPosY,
Float:vPosZ,
Float:vPosA,
}
new
vInfo[MAX_BUYABLE_VEH][_VINFO],
ivCreated[MAX_VEHICLES],
Total_Veh_Created;
pawn Код:
CMD:vcreate(playerid, params[])
{
new
Float:Pos[4],
ivModel,
ivColors[2],
Query[256],
iMsg[148];
new team;
if(sscanf(params, "iiii", ivModel, ivColors[0], ivColors[1], team)) return SendClientMessage(playerid, -1, ""#CRED"Usage: "#CORANGE"/VCreate < Vehicle Model > < Price > < Color 1 > < Color 2 >");
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
GetPlayerFacingAngle(playerid, Pos[3]);
++ Total_Veh_Created;
vInfo[Total_Veh_Created][vModel] = ivModel;
vInfo[Total_Veh_Created][vColor1] = ivColors[0];
vInfo[Total_Veh_Created][vColor2] = ivColors[1];
vInfo[Total_Veh_Created][vOwner] = team;
vInfo[Total_Veh_Created][vPosX] = Pos[0];
vInfo[Total_Veh_Created][vPosY] = Pos[1];
vInfo[Total_Veh_Created][vPosZ] = Pos[2];
vInfo[Total_Veh_Created][vPosA] = Pos[3];
format(Query, sizeof(Query), "INSERT INTO `privateveh` (`vID`, `vModel`, `vColor1`, `vColor2`, `vOwner`, `vPosX`, `vPosY`, `vPosZ`, `vPosA`) VALUES (%d, %d, %d, %d, %d, %f, %f, %f, %f)",
Total_Veh_Created,
ivModel,
ivColors[0],
ivColors[1],
team,
Pos[0],
Pos[1],
Pos[2],
Pos[3]);
mysql_query(Query);
new
cCar = CreateVehicle(ivModel, Pos[0], Pos[1], Pos[2], Pos[3], ivColors[0], ivColors[1], 500000);
//OwnedVeh(cCar) = Total_Veh_Created;
//SavePrivVeh(Total_Veh_Created);
format(iMsg, sizeof(iMsg), ""#CYELLOW"Vehicle: "#CBLUE"%i (VID: %i) "#CYELLOW"has been created. Price: "#CBLUE"$ "#CYELLOW"Plate: "#CBLUE"ChangeME", ivModel, Total_Veh_Created);
SendClientMessage(playerid, -1, iMsg);
return 1;
}
pawn Код:
stock LoadPVehicles()
{
new
Query[1024],
vModel2,
vC[2],
vOwner2,
Float:Pos[4],
vID;
mysql_query("SELECT * FROM `privateveh` WHERE `vID` < "#MAX_BUYABLE_VEH" ORDER BY vID");
mysql_store_result();
if(mysql_num_rows() > 0)
{
while(mysql_fetch_row(Query))
{
print("\n==============================================================\n");
sscanf(Query, "p<|>iiiiiffff",
vID, vModel2, vC[0], vC[1], vOwner2, Pos[0], Pos[1], Pos[2], Pos[3]);
printf("VID:\t\t%i", vID);
vInfo[vID][vModel] = vModel2; printf("Model:\t\t%i", vModel2);
vInfo[vID][vColor1] = vC[0]; printf("Color 1:\t%i", vC[0]);
vInfo[vID][vColor2] = vC[1]; printf("Color 2:\t%i", vC[1]);
//strmid(vInfo[vID][vOwner], vOwner2, 0, 24, 24); printf("Owner:\t\t%s", vOwner2);
vInfo[vID][vOwner] = vOwner2; printf("Owner: \t\t%i", vOwner2);
vInfo[vID][vPosX] = Pos[0]; printf("Spawn X:\t%f", Pos[0]);
vInfo[vID][vPosY] = Pos[1]; printf("Spawn Y:\t%f", Pos[1]);
vInfo[vID][vPosZ] = Pos[2]; printf("Spawn Z:\t%f", Pos[2]);
vInfo[vID][vPosA] = Pos[3]; printf("Spawn A:\t%f", Pos[3]);
print("\n==============================================================\n");
new
vCarID = CreateVehicle(vInfo[vID][vModel], vInfo[vID][vPosX], vInfo[vID][vPosY], vInfo[vID][vPosZ], vInfo[vID][vPosA], vInfo[vID][vColor1], vInfo[vID][vColor2], 500000);
//OwnedVeh(vCarID) = vID;
++ Total_Veh_Created;
}
}
mysql_free_result();
printf("** A total of: \"%i\" vehicle(s) were loaded!", Total_Veh_Created);
return Total_Veh_Created;
}
Now, i added a car to my team (team4). Car saving is good, the vOwner variable sets to 4.
I added a simple debug
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new iVehicleID = GetPlayerVehicleID(playerid);
if(vInfo[iVehicleID][vOwner] == PlayerData[playerid][Team])
{
SCM(playerid, COLOR_INFO, "good");
}
else
{
SCM(playerid, COLOR_INFO, "bad");
}
}
return 1;
}