Scratch idea for my server. -
Shockey HD - 07.08.2011
So here is it. My creating a zombie gamemode, and what i want is that if the player gets punched from a zombie, he will start loosing his health untill he goes and buy an antidote. How would i do this? Every 5 seconds he looses 5 Health
Re: Scratch idea for my server. -
PrawkC - 07.08.2011
I'd assume you'd use the OnPlayerShootPlayer include, assuming that supports fist being a weapon, or you could do something in OnPlayerStateChange to check if the zombie is in range of the player and pressed KEY_FIRE. then the other part with a timer.
Re: Scratch idea for my server. -
iPLEOMAX - 07.08.2011
As PrawkC said, Use OnPlayerKeyState change (KeyFire) > IsPlayerZombie? > IsUsingFists? > Loop through all players, see if a person is close enough to that player > SetTimerEx on targetplayer > Function:LowerPlayerHealth(playerid, amount);
When the victim uses a pill > KillTimer();
Thats what comes in my mind.
Re: Scratch idea for my server. -
Shockey HD - 07.08.2011
Im understanding what you mean. So it would be kinda like this?
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(PRESSED(KEY_FIRE))
{
new Float:x, Float:y, Float:z, hp;
GetPlayerPos(playerid, x, y, z);
{
if(IsPlayerInRangeOfPoint(i,x,y,z);
This is what i got, and im stuck
Re: Scratch idea for my server. -
iPLEOMAX - 07.08.2011
Go Ahead!
And wait a minute, I'll create a basic script too which you can modify with your taste.
Re: Scratch idea for my server. -
Shockey HD - 07.08.2011
Quote:
Originally Posted by iPLEOMAX
Go Ahead!
And wait a minute, I'll create a basic script too which you can modify with your taste. ![Smiley](images/smilies/smile.png)
|
Okay thank you very much :]
Re: Scratch idea for my server. -
iPLEOMAX - 07.08.2011
Made one quick, you may modify and tweak it.
pawn Код:
new
bool:g_Infected[MAX_PLAYERS],
bool:g_IsZombie[MAX_PLAYERS],
InfectedTimer[MAX_PLAYERS]
;
public OnPlayerSpawn(playerid)
{
KillTimer( InfectedTimer[playerid] );
g_Infected[playerid = false;
return true;
}
public OnPlayerDisconnect(playerid, reason)
{
KillTimer( InfectedTimer[playerid] );
g_Infected[playerid = false;
return true;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if( newkeys & KEY_FIRE && GetPlayerWeapon(playerid) == 0 )
{
if(g_IsZombie[playerid])
{
new Float:P[3];
GetPlayerPos(playerid, P[0], P[1], P[2]);
GetXYInFrontOfPlayer(playerid, P[0], P[1], 1);
for(new i=0; i<MAX_PLAYERS; i++)
{
if( IsPlayerConnected(i) && !IsPlayerNPC(i) )
{
if(i != playerid && !g_IsZombie[i] && !g_Infected[i] && IsPlayerInRangeOfPoint(i, 1, P[0], P[1], P[2]))
{
g_Infected[i] = true;
SendClientMessage(i, 0xFF0000FF, "You are attacked & infected by a Zombie! You are losing your health!");
SendClientMessage(i, 0xFF0000FF, "You need to use a Pill to before you die..");
InfectedTimer[i] = SetTimerEx("ReducePlayerHealth", 5000, true, "df", i, 5.0);
return true;
}
}
}
}
}
return true;
}
CMD:zombie(playerid, cmdtext[] )
{
if(g_IsZombie[playerid])
{
g_IsZombie[playerid] = false;
SendClientMessage(playerid, 0x00FF00FF, "You're no longer a Zombie.");
} else {
g_IsZombie[playerid] = true;
SendClientMessage(playerid, 0x00FF00FF, "You're a Zombie!");
}
return true;
}
stock ReducePlayerHealth(playerid, Float:amount)
{
if(amount > 100.0) return false;
new Float:HP; GetPlayerHealth(playerid, HP);
if(HP <= amount) SetPlayerHealth(playerid, 0.0);
SetPlayerHealth(playerid, HP-amount);
return true;
}
GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{ // Created by ******
new Float:a; GetPlayerPos(playerid, x, y, a); GetPlayerFacingAngle(playerid, a);
if (GetPlayerVehicleID(playerid)) { GetVehicleZAngle(GetPlayerVehicleID(playerid), a); }
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}
Re: Scratch idea for my server. -
dowster - 07.08.2011
Shockey, i made something like this for someone elses GM, i used a distance define so you would only get the closest player, and it would then check the distance to that player and see if it was less than 1 meter.
heres the distance define:
pawn Код:
#define DISTANCE(%1,%2,%3,%4,%5,%6) floatsqroot((%1-%4)*(%1-%4) + (%2-%5)*(%2-%5) + (%3-%6)*(%3-%6))
Re: Scratch idea for my server. -
Shockey HD - 08.08.2011
Quote:
Originally Posted by iPLEOMAX
Made one quick, you may modify and tweak it.
pawn Код:
new bool:g_Infected[MAX_PLAYERS], bool:g_IsZombie[MAX_PLAYERS], InfectedTimer[MAX_PLAYERS] ;
public OnPlayerSpawn(playerid) { KillTimer( InfectedTimer[playerid] ); g_Infected[playerid = false; return true; }
public OnPlayerDisconnect(playerid, reason) { KillTimer( InfectedTimer[playerid] ); g_Infected[playerid = false; return true; }
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if( newkeys & KEY_FIRE && GetPlayerWeapon(playerid) == 0 ) { if(g_IsZombie[playerid]) { new Float:P[3]; GetPlayerPos(playerid, P[0], P[1], P[2]); GetXYInFrontOfPlayer(playerid, P[0], P[1], 1); for(new i=0; i<MAX_PLAYERS; i++) { if( IsPlayerConnected(i) && !IsPlayerNPC(i) ) { if(i != playerid && !g_IsZombie[i] && !g_Infected[i] && IsPlayerInRangeOfPoint(i, 1, P[0], P[1], P[2])) { g_Infected[i] = true; SendClientMessage(i, 0xFF0000FF, "You are attacked & infected by a Zombie! You are losing your health!"); SendClientMessage(i, 0xFF0000FF, "You need to use a Pill to before you die.."); InfectedTimer[i] = SetTimerEx("ReducePlayerHealth", 5000, true, "df", i, 5.0); return true; } } } } } return true; }
CMD:zombie(playerid, cmdtext[] ) { if(g_IsZombie[playerid]) { g_IsZombie[playerid] = false; SendClientMessage(playerid, 0x00FF00FF, "You're no longer a Zombie."); } else { g_IsZombie[playerid] = true; SendClientMessage(playerid, 0x00FF00FF, "You're a Zombie!"); } return true; }
stock ReducePlayerHealth(playerid, Float:amount) { if(amount > 100.0) return false; new Float:HP; GetPlayerHealth(playerid, HP); if(HP <= amount) SetPlayerHealth(playerid, 0.0); SetPlayerHealth(playerid, HP-amount); return true; }
GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance) { // Created by ******
new Float:a; GetPlayerPos(playerid, x, y, a); GetPlayerFacingAngle(playerid, a); if (GetPlayerVehicleID(playerid)) { GetVehicleZAngle(GetPlayerVehicleID(playerid), a); } x += (distance * floatsin(-a, degrees)); y += (distance * floatcos(-a, degrees)); }
|
Okay it works good but, it actually dosnt take any health away from the player
Re: Scratch idea for my server. -
iiKyle - 08.08.2011
Tweak the ReducePlayerHealth,
Too Reduce the Player Health, i'd Think.
iiKyle