new Text3D:player_label[MAX_PLAYERS];
new Text3D:vehicle_label[MAX_VEHICLES];
public OnPlayerConnect(playerid)
{
player_label[playerid] = Create3DTextLabel("_", 0xFFFFFF00, 0, 0, 0, 30, 0, 1);
Attach3DTextLabelToPlayer(player_label[playerid], playerid, 0, 0, 0.4);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(User[playerid][ownedvehicle_id])
{
Delete3DTextLabel(vehicle_label[User[playerid][ownedvehicle_id]]);
DestroyVehicle(User[playerid][ownedvehicle_id]);
}
Delete3DTextLabel(player_label[playerid]);
return 1;
}
CMD:spawnvehicle(playerid, params[])
{
if(mode == MINIGUN_ID || mode == FREIGHTER_ID || mode == AREA51_ID || mode == STREET_ID || mode == ZOMBIE_ID || mode == AIL_ID || mode == HI_ID || mode == CP_ID)
return SendClientMessage(playerid, -1, "You cannot spawn your personal vehicle during this game round.");
if(User[playerid][accountLogged] == false) return SendClientMessage(playerid, COLOR_YELLOW, "You are not logged in.");
if(User[playerid][ownedvehicle] == 0) return SendClientMessage(playerid, COLOR_RED, "You do not own a vehicle.");
if(!IsPlayerSpawn(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be spawned to use this command.");
if(User[playerid][account_Objective] == true) return SendClientMessage(playerid, COLOR_RED, "You must be out of objective info screen first.");
if(User[playerid][SpecType] != ADMIN_SPEC_TYPE_NONE) return SendClientMessage(playerid, COLOR_RED, "You must not be on spectate mode to use this command.");
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You are already in a vehicle.");
if(User[playerid][ownedvehicle_id]) return SendClientMessage(playerid, COLOR_RED, "You have already spawned your personal vehicle.");
Delete3DTextLabel(vehicle_label[User[playerid][ownedvehicle_id]]);
DestroyVehicle(User[playerid][ownedvehicle_id]);
new Float:x, Float:y, Float:z, Float:a, string[128];
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
User[playerid][ownedvehicle_id] = CreateVehicle(User[playerid][ownedvehicle_model], x, y, z+1, a, User[playerid][ownedvehicle_color][0], User[playerid][ownedvehicle_color][1], -1);
LinkVehicleToInterior(User[playerid][ownedvehicle_id], GetPlayerInterior(playerid));
SetVehicleVirtualWorld(User[playerid][ownedvehicle_id], GetPlayerVirtualWorld(playerid));
PutPlayerInVehicle(playerid, User[playerid][ownedvehicle_id], 0);
format(string, sizeof string, "This %s is owned by %s(%d).", VehicleNames[User[playerid][ownedvehicle_model]-400], GetName(playerid), playerid);
vehicle_label[User[playerid][ownedvehicle_id]] = Create3DTextLabel(string, -1, 0, 0, 0, 80, 0, 1);
Attach3DTextLabelToVehicle(vehicle_label[User[playerid][ownedvehicle_id]], User[playerid][ownedvehicle_id], 0.0, 0.0, 0.0);
SendClientMessage(playerid, COLOR_YELLOW, "* You have spawned your personal vehicle.");
return 1;
}
CMD:destroyvehicle(playerid, params[])
{
if(User[playerid][accountLogged] == false) return SendClientMessage(playerid, COLOR_YELLOW, "You are not logged in.");
if(User[playerid][ownedvehicle] == 0) return SendClientMessage(playerid, COLOR_RED, "You do not own a personal vehicle.");
if(GetPVarInt(playerid, "destroy_vehicle"))
{
SendClientMessage(playerid, COLOR_YELLOW, "* Your vehicle has been destroyed.");
SendClientMessage(playerid, -1, "You may own a new one.");
if(User[playerid][ownedvehicle_id])
{
Delete3DTextLabel(vehicle_label[User[playerid][ownedvehicle_id]]);
DestroyVehicle(User[playerid][ownedvehicle_id]);
User[playerid][ownedvehicle_id] = 0;
}
//
User[playerid][ownedvehicle] = 0;
User[playerid][ownedvehicle_model] = 0;
User[playerid][ownedvehicle_color][0] = 0;
User[playerid][ownedvehicle_color][1] = 0;
//
DeletePVar(playerid, "destroy_vehicle");
}
else
{
SendClientMessage(playerid, -1, "You are about to delete your "red"personal vehicle"white".");
SendClientMessage(playerid, COLOR_YELLOW, "Type /destroyvehicle for the second time if you wanted to delete your personal vehicle.");
SetPVarInt(playerid, "destroy_vehicle", 1);
}
return 1;
}
// Below are the function LabelUpdate, I am not gonna post down the codes where this function is called in but let me give you a hint. This function is called when player gets promoted/demoted from admin,vip, Spawn Protection, Login.
stock LabelUpdate(i)
{
if(Spawn_Kill[i] == true)
{
Update3DTextLabelText(player_label[i], 0x28BA9AFF, "Spawn Protection");
return 1;
}
if(User[i][accountDuty] == 1)
{
Update3DTextLabelText(player_label[i], COLOR_GREEN, "Admin On Duty");
return 1;
}
if(User[i][accountAdmin] >= 1 && User[i][accountVip] == 1)
{
Update3DTextLabelText(player_label[i], COLOR_RED, "Admin"white"/{28BA9A}VIP");
}
else if(User[i][accountAdmin] >= 1 && User[i][accountVip] == 0)
{
Update3DTextLabelText(player_label[i], COLOR_RED, "Admin Staff");
}
else if(User[i][accountAdmin] == 0 && User[i][accountVip] == 1)
{
Update3DTextLabelText(player_label[i], 0x28BA9AFF, "VIP Member");
}
else if(User[i][accountAdmin] == 0 && User[i][accountVip] == 0)
{
Update3DTextLabelText(player_label[i], 0xFFFFFF00, "_");
}
return 1;
}
Delete3DTextLabel(vehicle_label[User[playerid][ownedvehicle_id]]);
if (IsValidVehicle(User[playerid][ownedvehicle_id]))
{
Delete3DTextLabel(vehicle_label[User[playerid][ownedvehicle_id]]);
DestroyVehicle(User[playerid][ownedvehicle_id]);
}
pawn Код:
Here you can do that by checking for vehicle instead (in your command: spawnvehicle) pawn Код:
|
This function exists within the SA-MP server, but it has not been defined within the include files. To use this function, you must first declare the appropriate native at the top of your script: 'native IsValidVehicle(vehicleid);'. It is recommended you place this under the inclusion of a_samp.inc |
stock VEH_IsValidVehicle(vehicleid)
{
return (400 <= GetVehicleModel(vehicleid) <= 611) ? true : false;
}
#if defined _ALS_IsValidVehicle
#undef IsValidVehicle
#else
#define _ALS_IsValidVehicle
#endif
#define IsValidVehicle VEH_IsValidVehicle
printf("player_label: %i | vehicle_label: %i", _:player_label[playerid], _:vehicle_label[User[playerid][ownedvehicle_id]]);