26.04.2010, 20:37
I need help with GetDistanceBetweenPlayers.
This is my /break command, and I can type /break [ID] and I can break them from anywhere, doesn't matter where they are and how far, I can break them. I'm not sure why my GetDistanceBetweenPlayers is not working. Is there a function i need to add to my script?
This is all i have
#define GetDistanceBetweenPlayers
This is my /break command, and I can type /break [ID] and I can break them from anywhere, doesn't matter where they are and how far, I can break them. I'm not sure why my GetDistanceBetweenPlayers is not working. Is there a function i need to add to my script?
This is all i have
#define GetDistanceBetweenPlayers
Код:
if(strcmp(cmd, "/break", true) == 0) {
if(IsSpawned[playerid] == 0) {
SendClientMessage(playerid, COLOR_ERROR, "You are dead. You cannot use this command");
return 1;
}
if(InDerby[playerid] == 1) {
SendClientMessage(playerid,COLOR_ERROR,"You cannot use this command while you are in the stadium");
return 1;
}
if(gTeam[playerid] != TEAM_MECHANIC) {
SendClientMessage(playerid,COLOR_ERROR,"You are not a Car Mechanic");
return 1;
}
if(fixedcarrecent[playerid] >=1) {
SendClientMessage(playerid,COLOR_ERROR,"Command used recently. Please wait");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /break (id)");
return 1;
}
giveplayerid = strval(tmp);
if(!IsNumeric(tmp)) {
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /break (id) ID Must be a number");
return 1;
}
if(!IsPlayerConnected(giveplayerid)) {
format(szstring, sizeof(szstring), "ID (%d) is not an active player", giveplayerid);
SendClientMessage(playerid, COLOR_ERROR, szstring);
return 1;
}
if(GetDistanceBetweenPlayers(playerid,giveplayerid) > 3) {
format(szstring, sizeof(szstring), "(%d) Is not close enough. You cannot pour sand into that players vehicle engine",giveplayerid);
SendClientMessage(playerid, COLOR_ERROR, szstring);
return 1;
}
GetPlayerName(playerid,mname, 24);
GetPlayerName(giveplayerid, pname, 24);
if(!IsPlayerInAnyVehicle(giveplayerid)) {
format(szstring, sizeof(szstring), "%s(%d) is not in any vehicle",pname,giveplayerid);
SendClientMessage(playerid, COLOR_ERROR, szstring);
return 1;
}
if(GetPlayerState(giveplayerid) == PLAYER_STATE_DRIVER) {
if(GetVehicleModel(GetPlayerVehicleID(giveplayerid)) == 481) {
SendClientMessage(playerid, COLOR_ERROR, "That vehicle does not have any engine, you cannot use this command on that vehicle (BMX Bike)");
return 1;
}
new tobreak = GetPlayerVehicleID(giveplayerid);
oscore = GetPlayerScore(playerid);
SandInEngine[tobreak] =1;
SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Sand In Engine_|");
format(szstring, sizeof(szstring), "Mechanic %s(%d) has filled your vehicle engine with sand. GET OUT",mname,playerid);
SendClientMessage(giveplayerid,COLOR_DODGERBLUE, szstring);
SendClientMessage(playerid, 0xA9A9A9AA, "|_Sand In Engine_|");
format(szstring, sizeof(szstring), "You have filled %s(%d)'s vehicle engine with sand", pname,giveplayerid);
SendClientMessage(playerid,COLOR_DODGERBLUE, szstring);
new plwl = GetPlayerWantedLevel(playerid);
SetPlayerWantedLevel(playerid, plwl +1 );
commitedcrimerecently[playerid] +=60;
fixedcarrecent[playerid] =60;
SetPlayerScore(playerid, oscore +1);
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
if(LawEnforcementRadio[i] == 1)
{
new current_zone;
current_zone = player_zone[playerid];
format(szstring, sizeof(szstring), "DISPATCH: (CRIME IN PROGRESS) SUSPECT: %s(%d) CRIME: Criminal Damage LOCATION: %s",mname,playerid,zones[current_zone][zone_name]);
SendClientMessage(i,COLOR_ROYALBLUE, szstring);
}
}
}
new pcol = GetPlayerColor(playerid);
plwl = GetPlayerWantedLevel(playerid);
SendClientMessage(playerid, 0xA9A9A9AA, "|_Crime Commited_|");
format(szstring, sizeof(szstring), "(CRIMINAL DAMAGE) Wanted Level %d",plwl);
SendClientMessage(playerid,pcol,szstring);
}
else{
format(szstring, sizeof(szstring), "%s(%d) is not the driver of the vehicle",pname,giveplayerid);
SendClientMessage(giveplayerid,COLOR_DODGERBLUE, szstring);
}
return 1;
}

