23.02.2008, 15:38
Код:
if (strcmp(cmdtext, "/rape", true)==0) { if ((GetTickCount() - gPlayerLastRape[playerid]) >= RAPE_MIN_WAIT) { new victim = INVALID_PLAYER_ID; if (IsPlayerInAnyVehicle(playerid)) { new vehicle = GetPlayerVehicleID(playerid); for(new i=0; i < MAX_PLAYERS; i++) { if(i != playerid && IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && GetPlayerVehicleID(i) == vehicle) { victim = i; break; } } } else if (GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) { new Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, Float:distance; GetPlayerPos(playerid, x1, y1, z1); for(new i=0; i < MAX_PLAYERS; i++) { if(i != playerid && IsPlayerConnected(i) && GetPlayerState(i) == PLAYER_STATE_ONFOOT) { GetPlayerPos(i, x2, y2, z2); distance = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2)); if(distance < RAPE_MAX_DISTANCE) { victim = i; break; } } } } if (victim != INVALID_PLAYER_ID) { new name[MAX_PLAYER_NAME], str[256]; GetPlayerName(victim, name, MAX_PLAYER_NAME); new rand = random(100); gPlayerLastRape[playerid] = GetTickCount(); if (rand <= RAPE_SUCCESS_PERCENTAGE) { GetPlayerName(playerid, name, MAX_PLAYER_NAME); format(str, sizeof(str), "%s (%d) has raped you and gave you %s", name, playerid,STI[rand][0]); SendClientMessage(victim, COLOR_RED, str); format(str, sizeof(str), "%s raped someone and gave him/her %s", name, victim, STI[rand][0]); SendClientMessageToAll(COLOR_RED,str); format(str, sizeof(str), "~y~Raped by %s.", name); GameTextForPlayer(victim, str, 3000, 3); new Float:health; GetPlayerHealth(victim, health); SetPlayerHealth(victim, health -10); GetPlayerName(victim, name, MAX_PLAYER_NAME); format(str, sizeof(str), "You have raped %s (%d) and infected him/her with %s", name, victim,STI[rand][0]); SendClientMessage(playerid, RAPE_SUCCESS, str); format(str, sizeof(str), "~y~Raped %s.", name); GameTextForPlayer(playerid, str, 3000, 3); SetPlayerScore(playerid, GetPlayerScore(playerid) +1); } else { GetPlayerName(playerid, name, MAX_PLAYER_NAME); format(str, sizeof(str), "%s (%d) has attempted to rape you but failed.", name, playerid); SendClientMessage(victim, RAPE_FAILURE, str); format(str, sizeof(str), "~y~%s attempted to rape you", name); GameTextForPlayer(victim, str, 3000, 3); GetPlayerName(victim, name, MAX_PLAYER_NAME); format(str, sizeof(str), "Your attempt to rape %s (%d) has failed.", name, victim); SendClientMessage(playerid, RAPE_FAILURE, str); format(str, sizeof(str), "~y~Attempt to rape %s failed", name); GameTextForPlayer(playerid, str, 3000, 3); } } else { SendClientMessage(playerid, RAPE_ERROR, "No players close enough to rape."); } } else { SendClientMessage(playerid, RAPE_ERROR, "Please wait before attempting to rape someone again."); } return true; }