30.04.2012, 21:12
Taze
Cuff
PHP код:
dcmd_taze(playerid, params[])
{
if(gTeam[playerid] == TEAM_COP || gTeam[playerid] == TEAM_AIRCOP || gTeam[playerid] == TEAM_MARINECOP || gTeam[playerid] == TEAM_SWAT || gTeam[playerid] == TEAM_ARMY)
{
new targetid, string[128];
new playername[MAX_PLAYER_NAME], targetname[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
GetPlayerName(targetid, targetname, sizeof(targetname));
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_USAGE, "USAGE: /taze (id)");
else if(gTeam[targetid] == TEAM_COP && gTeam[targetid] == TEAM_AIRCOP && gTeam[targetid] == TEAM_MARINECOP && gTeam[targetid] == TEAM_SWAT && gTeam[targetid] == TEAM_ARMY) return SendClientMessage(playerid, COLOR_ERROR, "You cannot taze another Law Enforcement agent");
else if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_ERROR, "Invalid ID");
else if(playerid == targetid) return SendClientMessage(playerid, COLOR_ERROR, "You cannot taze yourself!");
else if(IsSpawned[playerid] == 0) return SendClientMessage(playerid, COLOR_ERROR, "You are dead. You cannot use this command");
else if(Jailed[playerid] == 1) return SendClientMessage(playerid, COLOR_ERROR, "You cannot use this command in jail");
else if(GetPlayerWantedLevel(targetid) <= 3)
{
format(string, sizeof(string), "%s(%d) Does not have a warrant. You cannot use your tazer on this player", targetname, targetid);
SendClientMessage(playerid, COLOR_ERROR, string);
return 1;
}
else if(Tazed[targetid] == 1)
{
format(string, sizeof(string), "%s(%d) Is being tazed right now. You cannot taze a player while the player is being tazed", targetname, targetid);
SendClientMessage(playerid, COLOR_ERROR, string);
}
else if(GetDistanceBetweenPlayers(playerid, targetid) > 10)
{
format(string, sizeof(string), "%s(%d) Is not close enough to taze", targetname, targetid);
SendClientMessage(playerid, COLOR_ERROR, string);
return 1;
}
else if(Cuffed[targetid] == 1)
{
format(string, sizeof(string), "%s(%d) Is in handcuffs and is restrained. You cannot taze a handcuffed player", targetname, targetid);
SendClientMessage(playerid, COLOR_ERROR, string);
return 1;
}
else if(IsPlayerInAnyVehicle(targetid))
{
format(string, sizeof(string), "%s(%d) Is in a vehicle. Get the player out the vehicle then use your tazer", targetname, targetid);
SendClientMessage(playerid, COLOR_ERROR, string);
return 1;
}
else if(IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, COLOR_ERROR, "You cannot taze a player from inside a vehicle");
return 1;
}
else
{
new FileL[68];
format(FileL, sizeof(FileL) , SERVER_USER_FILE , playername);
dini_IntSet(FileL, "Taze" , UserInfo[playerid][Taze]);
UserInfo[playerid][Taze] ++;
Tazed[targetid] =1;
TogglePlayerControllable(targetid, 0);
format(string, sizeof(string), "Law Enforcement agent %s(%d) Has tazed suspect %s(%d)", playername, playerid, targetname, targetid);
SendClientMessageToAll(0x00C7FFAA, string);
format(string, sizeof(string), "Officer %s(%d) Has tazed you", playername, playerid);
SendClientMessage(targetid, COLOR_DODGERBLUE, string);
ApplyAnimation(targetid,"PED","BIKE_fall_off",4.1,0,1,1,1,1);
SetTimer("Tazingtime", 3000, false);
return 1;
}
}
return 0;
}
PHP код:
if(strcmp(cmd, "/cuff", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /cuff [playerid]");
}
giveplayerid = strval(tmp);
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if(gTeam[playerid] == TEAM_COP && PlayerInfo[playerid][pRank] == 1 || gTeam[playerid] == TEAM_ARMY && PlayerInfo[playerid][pRank] == 2)
{
if(PlayerToPoint(7.5, giveplayerid, x , y, z))
{
if(gTeam[playerid] == TEAM_COP && PlayerInfo[playerid][pRank] == 1 || gTeam[playerid] == TEAM_ARMY && PlayerInfo[playerid][pRank] == 2 && IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin] >= 104)
{
format(string, sizeof(string), "Officer %s has cuffed (suspect) %s", PlayerName[playerid], PlayerName[giveplayerid]);
SendClientMessageToAll(COLOR_BLUE, string);
TogglePlayerControllable(giveplayerid, false);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED, "You could not cuff an officer that follows the law to.");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "That playerid is not close (enough) to you!");
}
}
else
{
SendClientMessage(playerid, COLOR_RED,"You are not a part of the cops team.");
}
return 1;
}