24.02.2009, 13:56
So , i have this code :
How could I make a checkpoint to cure the people and delete the /cure command ?
Code:
#include <a_samp>
#define filterscript
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define NUMVALUES 4
/* EDIT FROM HERE*/
#define COLOR_ERROR 0xFF0000FF //Color of the error messages
#define COLOR_MSG 0x00FFFFFF //Color of general messages
#define ANTISPAM_RAPE 5 //Minimum time between /rape commands (in seconds)
#define ANTISPAM_CURE 25 //Minimum time between /cure commands (in seconds)
#define CHLAMYDIA 3 //The interval which the player loses health with Chlamydia (in seconds)
#define GONORRHEA 2 //The interval which the player loses health with Gonorrhea (in seconds)
#define RAPE_DISTANCE 5.0 //Distance between players to be able to rape
/*NO NEED TO EDIT FROM HERE*/
stock Float:GetDistanceBetweenPlayers(p1,p2){
new Float:x1,Float:y1,Float:z1,Float:x3,Float:y3,Float:z3;
if (!IsPlayerConnected(p1) || !IsPlayerConnected(p2)){
return -1.00;
}
GetPlayerPos(p1,x1,y1,z1);
GetPlayerPos(p2,x3,y3,z3);
return floatsqroot(floatpower(floatabs(floatsub(x3,x1)),2)+floatpower(floatabs(floatsub(y3,y1)),2)+floatpower(floatabs(floatsub(z3,z1)),2));
}
new string[256];
new chlamydia[MAX_PLAYERS];
new gonorrhea[MAX_PLAYERS];
new rapespam[MAX_PLAYERS];
new curespam[MAX_PLAYERS];
stock ReturnPlayerName(id)
{
new thename[MAX_PLAYER_NAME];
GetPlayerName(id, thename, MAX_PLAYER_NAME);
return thename;
}
dcmd_rape(playerid, params[])
{
new ID = strval(params);
if(!strlen(params))
{
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /rape [ID]");
}
else
{
if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_ERROR, "That player is not connected!");
if(ID == playerid) return SendClientMessage(playerid, COLOR_ERROR, "You cannot rape yourself!");
if(rapespam[playerid] == 0)
{
if(GetDistanceBetweenPlayers(playerid,ID) > RAPE_DISTANCE) return SendClientMessage(playerid, COLOR_ERROR, "You are not close enough to eachother!");
new raperand = random(5);
if(raperand == 1 || raperand == 2)
{
format(string, sizeof(string), "%s (%i) noticed you trying to rape him", ReturnPlayerName(ID), ID);
SendClientMessage(playerid, COLOR_MSG, string);
format(string, sizeof(string), "%s (%i) tried to rape you", ReturnPlayerName(playerid), playerid);
SendClientMessage(ID, COLOR_MSG, string);
}
else if(raperand == 3 || raperand == 5)
{
if(!chlamydia[ID])
{
chlamydia[ID] = 1;
new Float:health;
GetPlayerHealth(ID, health);
SetPlayerHealth(ID, health-5-random(10));
format(string, 256, "You raped and infected %s (%i) with Chlamydia", ReturnPlayerName(ID), ID);
SendClientMessage(playerid, COLOR_MSG, string);
format(string, sizeof(string), "%s (%i) raped you and infected you with Chlamydia", ReturnPlayerName(playerid), playerid);
SendClientMessage(ID, COLOR_MSG, string);
}
else
{
new Float:health;
GetPlayerHealth(ID, health);
SetPlayerHealth(ID, health-5-random(15));
format(string, 256, "You raped %s (%i)", ReturnPlayerName(ID), ID);
SendClientMessage(playerid, COLOR_MSG, string);
format(string, sizeof(string), "%s (%i) raped you", ReturnPlayerName(playerid), playerid);
SendClientMessage(ID, COLOR_MSG, string);
}
}
else if(raperand == 4)
{
if(!gonorrhea[ID])
{
gonorrhea[ID] = 1;
new Float:health;
GetPlayerHealth(ID, health);
SetPlayerHealth(ID, health-5-random(20));
format(string, 256, "You raped and infected %s (%i) with Gonorrhea", ReturnPlayerName(ID), ID);
SendClientMessage(playerid, COLOR_MSG, string);
format(string, sizeof(string), "%s (%i) raped you and infected you with Gonorrhea", ReturnPlayerName(playerid), playerid);
SendClientMessage(ID, COLOR_MSG, string);
}
else
{
new Float:health;
GetPlayerHealth(ID, health);
SetPlayerHealth(ID, health-5-random(20));
format(string, 256, "You raped %s (%i)", ReturnPlayerName(ID), ID);
SendClientMessage(playerid, COLOR_MSG, string);
format(string, sizeof(string), "%s (%i) raped you", ReturnPlayerName(playerid), playerid);
SendClientMessage(ID, COLOR_MSG, string);
}
}
rapespam[playerid] = 1;
SetTimerEx("rapespamt", ANTISPAM_RAPE*1000, false, "i", playerid);
}
else
{
SendClientMessage(playerid, COLOR_ERROR, "Please wait before raping someone again!");
}
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(rape, 4, cmdtext);
if(!strcmp(cmdtext, "/cure", true))
{
if(curespam[playerid] == 0)
{
if(chlamydia[playerid] || gonorrhea[playerid])
{
new randcure = random(3);
if(randcure == 1 || randcure == 2)
{
SendClientMessage(playerid, COLOR_MSG, "You tried to cure yourself by poking yourself in random places with a needle but it failed");
}
else
{
SendClientMessage(playerid, COLOR_MSG, "You tried to cure yourself by poking yourself in random places with a needle and it worked!!");
SendClientMessage(playerid, COLOR_MSG, "You are now cured from all diseases!");
chlamydia[playerid] = 0;
gonorrhea[playerid] = 0;
}
SetTimerEx("curespamt", ANTISPAM_CURE*1000, false, "i", playerid);
curespam[playerid] = 1;
}
else
{
SendClientMessage(playerid, COLOR_ERROR, "You don't have any STDs to cure!");
}
}
else
{
SendClientMessage(playerid, COLOR_ERROR, "Please wait before trying to cure yourself again!");
}
return 1;
}
return 0;
}
public OnFilterScriptInit()
{
SetTimer("checkchlamy", CHLAMYDIA*1000, true);
SetTimer("checkgono", GONORRHEA*1000, true);
}
public OnPlayerDeath(playerid, killerid, reason)
{
chlamydia[playerid] = 0;
gonorrhea[playerid] = 0;
}
forward checkchlamy();
public checkchlamy()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(chlamydia[i] == 1 && IsPlayerConnected(i))
{
new Float:health;
GetPlayerHealth(i, health);
SetPlayerHealth(i, health-5-random(10));
}
}
}
forward checkgono();
public checkgono()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(gonorrhea[i] == 1 && IsPlayerConnected(i))
{
new Float:health;
GetPlayerHealth(i, health);
SetPlayerHealth(i, health-5-random(20));
}
}
}
forward rapespamt(Id);
public rapespamt(Id)
{
rapespam[Id] = 0;
}
forward curespamt(id);
public curespamt(id)
{
curespam[id] = 0;
}

