30.06.2016, 19:15
Hello, why does this command not place the 3d text label on the closest vehicle?
pawn Код:
if(strcmp(cmd, "/parkingticket", true) == 0)
{
new vehicleid=GetClosestCar(playerid);
if(IsPlayerConnected(playerid))
{
if(gTeam[playerid] != 2)
{
SendClientMessage(playerid, COLOR_GREY, " You are not a Cop!");
return 1;
}
if(OnDuty[playerid] != 1 && PlayerInfo[playerid][pMember] == 1)
{
SendClientMessage(playerid, COLOR_GREY, " You are not on Duty!");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, ""COL_SZR"Usage:"COL_WHITE" /parkingticket [price] [reason]");
return 1;
}
new price;
price = strval(tmp);
if(price < 1 || price > 1000) { SendClientMessage(playerid, COLOR_GREY, " The parking ticket price can't be below 1 or higher than 1000."); return 1; }
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GRAD2, ""COL_SZR"Usage:"COL_WHITE" /parkingticket [price] [reason]");
return 1;
}
new Float:x, Float:y, Float:z;
GetVehiclePos(vehicleid, x, y, z);
format(string,sizeof(string),"Parking Ticket: Price: $%d Reason: %s", price, result);
vehicle3Dtext[vehicleid] = Create3DTextLabel(string, TEAM_SAS_COLOR, x, y, z, 10, 0, 1);
Attach3DTextLabelToVehicle(vehicle3Dtext[vehicleid], vehicleid, 0.0, -2.8, 0.0);
CarInfo[vehicleid][cParkTicket] = 1;
strmid(CarInfo[vehicleid][cPtText], result, 0, 64, 255);
format(string, sizeof(string), "* %s writes down a parking ticket, and places it on the %s's windshield wiper.", RemoveUnderScore(playerid),vehName[GetVehicleModel(vehicleid)-400]);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
return 1;
}
return 1;
}