09.10.2014, 11:53
Well, I tried to Attach3DTextLabelToVehicle when any player does /ac and Delete the label with /unac, but it seems that I did something wrong as the text would always appear as "-1", even when I do /unac it doesn't delete it.
I hope someone can help me out with it.
Here are the commands:
I hope someone can help me out with it.
Here are the commands:
pawn Код:
CMD:ac(playerid, params[]) {
return cmd_assigncar(playerid, params);
}
CMD:assigncar(playerid, params[])
{
if(PlayerInfo[playerid][pDispatchOn] == 1)
{
new giveplayerid, vehicleid, carnum, string[128];
if(!sscanf(params, "ii", giveplayerid, vehicleid))
{
if(IsPlayerConnected(giveplayerid))
{
if(IsACop(playerid) || IsALVMPDCop(playerid))
{
new hours, minutes, seconds;
new callsign[10];
gettime(hours, minutes, seconds);
GetPlayerCallSign(giveplayerid, callsign);
carnum = GetNextCarSlot();
format(string, sizeof(string), "** DISPATCH-%d: %s-%d has been assigned to car number %d [%d:%d:%d]**", playerid, callsign, PlayerInfo[giveplayerid][pBadgeNum], vehicleid, hours, minutes, seconds);
SendDispatchMessage(string);
AssignDispatchCar(giveplayerid, carnum, vehicleid);
}
else
{
SendClientMessageEx(playerid, COLOR_GRAD2, " That player is not a cop!");
return 1;
}
}
else
{
SendClientMessageEx(playerid, COLOR_GRAD2, " That player is not connected.");
return 1;
}
}
else
{
SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /assigncar [Player ID] [Vehicle ID]");
return 1;
}
}
else
{
SendClientMessageEx(playerid, COLOR_GRAD2, "You are not online as a dispatcher!");
SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /dpon");
return 1;
}
return 1;
}
CMD:uac(playerid, params[]) {
return cmd_unassigncar(playerid, params);
}
CMD:unassigncar(playerid, params[])
{
if(PlayerInfo[playerid][pDispatchOn] == 1)
{
new carnum, vehicleid, string[128];
if(!sscanf(params, "i", vehicleid))
{
for(new v=0; v<MAX_DP_CARS; v++)
{
if(DPCar[v][dpCarID] == vehicleid) carnum = v;
}
if(DPCar[carnum][dpCarID] != 0)
{
new hours, minutes, seconds;
new callsign[10];
gettime(hours, minutes, seconds);
GetPlayerCallSign(DPCar[carnum][dpOfficerID], callsign);
format(string, sizeof(string), "** DISPATCH-%d: %s-%d has been un-assigned from car number %d [%d:%d:%d]**", playerid, callsign, PlayerInfo[DPCar[carnum][dpOfficerID]][pBadgeNum], DPCar[carnum][dpCarID], hours, minutes, seconds);
SendDispatchMessage(string);
UnAssignDispatchCar(carnum);
}
else
{
SendClientMessageEx(playerid, COLOR_GRAD2, " This car has not been assigned.");
return 1;
}
}
else
{
SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /unassigncar [Vehicle ID]");
return 1;
}
}
else
{
SendClientMessageEx(playerid, COLOR_GRAD2, "You are not online as a dispatcher!");
SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /dpon");
return 1;
}
return 1;
}
pawn Код:
forward AssignDispatchCar(playerid, carnum, vehicleid);
public AssignDispatchCar(playerid, carnum, vehicleid)
{
new rank[64], division[64], employer[64], callsign[64], string[64];
GetPlayerFactionInfo(playerid, rank, division, employer);
DPCar[carnum][dpCarID] = vehicleid;
format(DPCar[carnum][dpFaction], 10, "%s", employer);
format(DPCar[carnum][dpModel], 24, "%s", GetVehicleName(vehicleid));
DPCar[carnum][dpOfficerID] = playerid;
format(string, sizeof(string), "%s-%d", callsign, PlayerInfo[playerid][pBadgeNum]);
Dispatch3DText[vehicleid] = Create3DTextLabel(string, 0xC8C8C8C8, 0.0, 0.0, 0.0, 40.0, 0, 1 );
Attach3DTextLabelToVehicle(Dispatch3DText[vehicleid] , vehicleid, 2.0, -2.0, 0.0);
}
forward UnAssignDispatchCar(carnum);
public UnAssignDispatchCar(carnum)
{
new vehicleid;
DPCar[carnum][dpCarID] = 0;
format(DPCar[carnum][dpFaction], 10, "None");
format(DPCar[carnum][dpModel], 24, "None");
Delete3DTextLabel(Dispatch3DText[vehicleid]);
DPCar[carnum][dpOfficerID] = -1;
}