21.06.2012, 13:52
I have a command if i type /class and select Invincible,Then it activates invincible and if you press JUMP_KEy it makes you invincible for 7 seconds.I have made a timer so that it can be only used once 50 seconds here are my code.
on top
OnPlayerSpawn
Under OnPlayerKeyStateChange
and here the forward'
and here's my Dialog
i really need it ...
no errors
Will +Rep if you want.
on top
pawn Код:
new IsInvincible[MAX_PLAYERS];
new ClassSelectedInvin[MAX_PLAYERS];
new ClassTimerInvinVar;
pawn Код:
IsInvincible[playerid] = 0;
ClassSelectedInvin[playerid] = 0;
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys == KEY_JUMP)
{
IsInvincible[playerid] = 0;
SetPlayerHealth(playerid,99999);
SetTimerEx("Invincible",7000,0, "i", playerid);
pawn Код:
forward ClassTimerInvin(playerid);
public ClassTimerInvin(playerid)
{
ClassSelectedInvin[playerid] = 0;
KillTimer(ClassTimerInvinVar);
return 1;
}
forward Invincible(playerid);
public Invincible(playerid)
{
if(IsInvincible[playerid] == 0) return IsInvincible[playerid] = 1;
SetPlayerHealth(playerid,50);
SendClientMessage(playerid,-1,"You are now Un-Invincible");
return 1;
pawn Код:
if(dialogid == 4)
{
if(!response) return ShowPlayerDialog(playerid,-1,0,"","","","");
if(response)
{
switch(listitem)
{
case 0:
{
if(IsInvincible[playerid] == 1)
{
SendClientMessage(playerid,-1,"You need to wait 50 Secods before using this class again");
}
else if(IsInvincible[playerid] == 0)
{
IsInvincible[playerid] = 1;
ClassSelectedInvin[playerid] = 1;
SendClientMessage(playerid, -1, "Invincible Class Activated");
SendClientMessage(playerid,-1, "Press Jump_Key To Activated Invincible Mode");
ClassTimerInvinVar = SetTimer("ClassTimerInvin",50000,false);
}
}
}
no errors
Will +Rep if you want.