17.05.2012, 06:05
I have a vehicle system, that loads teamid's and things.
I was wondering, how could I get it so that I can check it against the teamid under OnPlayerStateChange?
For instance:
Here is my vehicle system:
So how could I check if the player is in the same team as the vehicles team slot?
Thanks!
I was wondering, how could I get it so that I can check it against the teamid under OnPlayerStateChange?
For instance:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(GetPlayerTeam(playerid) != THEVEHICLEVAR)
{
SendClientMessage(playerid, WHITE, "This vehicle isn't for you.");
RemovePlayerFromVehicle(playerid);
}
else
{
return 1;
}
return 1;
}
pawn Код:
stock LoadVehicles()
{
new
Str[128],
dModel,
Float:VX,
Float:VY,
Float:VZ,
Float:VA,
Team,
col1,
col2,
vTotal;
mysql_query("SELECT * FROM `vehicles`");
mysql_store_result();
if(mysql_num_rows() > 0)
{
while(mysql_fetch_row(Str))
{
sscanf(Str, "p<|>iffffiii", dModel, VX, VY, VZ, VA, Team, col1, col2);
CreateVehicle(dModel, VX, VY, VZ, VA, col1, col2, -1);
vTotal++;
}
}
mysql_free_result();
printf("%i vehicles loaded from the MySQL Database.", vTotal);
return 1;
}
//this is for saving them after a command to create them
stock SaveVehicle(Float:VX, Float:VY, Float:VZ, Float:VA, dModel, Team, col1, col2)
{
new
Query[1024];
format(Query, sizeof(Query), "INSERT INTO `vehicles` (VehicleModel, VehicleX, VehicleY, VehicleZ, VehicleAngle, Team, Colour1, Colour2) VALUES(%d, %f, %f, %f, %f, %d, %i, %i)",
dModel, VX, VY, VZ, VA, Team, col1, col2);
mysql_query(Query);
mysql_free_result();
return 1;
}
//here is the command
command(addvehicle, playerid, params[])
{
if(Player[playerid][AdminLevel] >= 5)
{
new
Float:VX,
Float:VY,
Float:VZ,
Float:VA,
Team,
col1,
col2,
dModel = GetVehicleModel(GetPlayerVehicleID(playerid)),
vehicleid = GetPlayerVehicleID(playerid),
Msg[128];
if(sscanf(params, "dii", Team, col1, col2)) return SendClientMessage(playerid, WHITE, "Server: /addvehicle [teamid] [color 1] [color 2]");
{
GetVehiclePos(vehicleid, VX, VY, VZ);
GetVehicleZAngle(vehicleid, VA);
if(IsPlayerInAnyVehicle(playerid))
{
SaveVehicle(Float:VX, Float:VY, Float:VZ, Float:VA, dModel, Team, col1, col2);
format(Msg, sizeof(Msg), "A new vehicle Has Been dynamically added. Model: (%d).", dModel);
return SendClientMessage(playerid, WHITE, Msg);
}
else return SendClientMessage(playerid, WHITE, "You must be in a vehicle!");
}
}
else return SendClientMessage(playerid, WHITE, NotAllowed);
}
Thanks!