Need some help on a /defuse command
#1

For this coding

Код:
 if (strcmp(cmd, "/plantbomb", true) ==0 )
		{
		    if(PlayerInfo[playerid][pBomb] < 1)
		    {
		        SendClientMessage(playerid, COLOR_BLUE, "You don't have bombs");
                return 1;
		    }
		    if(IsPlayerInAnyVehicle(playerid))
		    {
		        PlayerInfo[playerid][pBomb] = 0;
			    TogglePlayerControllable(playerid, 0);
			    SetTimerEx("BombTimer2", 5000, 0, "d", playerid);
			    format(string, sizeof(string), "%s begins to plant a bomb.", GetPlayerNameEx(playerid));
				ProxDetector(5.0, playerid, string,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
				return 1;
		    }
		    PlayerInfo[playerid][pBomb] = 0;
		    TogglePlayerControllable(playerid, 0);
		    ApplyAnimation(playerid, "BOMBER","BOM_Plant_Loop",4.0,1,0,0,0,0);
		    SetTimerEx("BombTimer2", 5000, 0, "d", playerid);
		    format(string, sizeof(string), "%s begins to plant a bomb.", GetPlayerNameEx(playerid));
			ProxDetector(5.0, playerid, string,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
			return 1;
		}

forward BombTimer2(playerid);
public BombTimer2(playerid)
{
    GetPlayerPos(playerid, bombx, bomby, bombz);
	TheBomb[playerid] = CreatePickup(1252, 1, bombx, bomby, bombz, -1);
	TogglePlayerControllable(playerid, 1);
	ClearAnimations(playerid);
	SendClientMessage(playerid, COLOR_SPRINGGREEN, "The Bomb explodes in 20 Seconds! RUN!");
	BombExplosion[playerid] = 20;
	BombingTime2[playerid] = SetTimerEx("BombTimer3", 1000, 1, "d", playerid);
	return 1;
}

forward BombTimer3(playerid);
public BombTimer3(playerid)
{
    new string[128];
	if(BombExplosion[playerid] == 0)
	{
	    CreateExplosion(bombx, bomby, bombz, 6, 100.0);
	    for(new i = 0; i < MAX_PLAYERS; i++)
		{
	        if(IsPlayerInRangeOfPoint(i, 100.0, bombx, bomby, bombz))
	        {

	            SendClientMessage(i, COLOR_SPRINGGREEN, "You have been caughten up in the bomb explosion");
	            ApplyAnimation(i, "WUZI", "CS_Dead_Guy", 4.0, 0, 0, 0, 0, 0); // Dead Crawling
	            GivePlayerHealth(i, -90);
	            DestroyPickup(TheBomb[i]);
	            ApplyAnimation(i, "WUZI", "CS_Dead_Guy", 4.0, 0, 0, 0, 0, 0); // Dead Crawling
	        }
		}
        KillTimer(BombingTime2[playerid]);
        return 1;
	}
	PlayerPlaySound(playerid, 1132, bombx, bomby, bombz);
    BombExplosion[playerid] --;
    format(string, 256, "~g~~>~Time Left~w~ - %d~<~", BombExplosion[playerid]);
    GameTextForPlayer(playerid, string, 1000, 4);
    return 1;
}

forward BombTimer(playerid);
public BombTimer(playerid)
{
	new string[128];
	if(BombTime[playerid] == 0)
	{
	    KillTimer(BombingTime[playerid]);
	    TogglePlayerControllable(playerid, 1);
		ClearAnimations(playerid);
		SendClientMessage(playerid, COLOR_SPRINGGREEN, "You have made yourself a bomb!");
		PlayerInfo[playerid][pBomb] = 1;
		PlayerInfo[playerid][pBombMats] = 0;
	    return 1;
	}
    BombTime[playerid] --;
    format(string, 256, "~r~~>~Time Left~w~ - %d~<~", BombTime[playerid]);
    GameTextForPlayer(playerid, string, 1000, 4);
    return 1;
}
I have been trying to convert this /defuse command into this one..

Код:
if(strcmp(cmd, "/defuse", true) == 0)
	{
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
	  			if(PlayerInfo[playerid][pFaction] != 255 && DynamicFactions[PlayerInfo[playerid][pFaction]][fType] != 1)
				{
					SendClientMessage(playerid, COLOR_GREY, "[Error:] Invalid faction");
					return 1;
				}
				if(CopOnDuty[playerid] == 0)
				{
		 			SendClientMessage(playerid, COLOR_GREY, "[Error:] You are not on duty");
					return 1;
				}
				if(IsPlayerInAnyVehicle(playerid))
				{
					return 1;
				}
	           	new Float:bx[MAX_PLAYERS], Float:by[MAX_PLAYERS], Float:bz[MAX_PLAYERS];
				GetObjectPos(C4[i], bx[i], by[i], bz[i]);
	   			if(IsPlayerInRangeOfPoint(playerid, 2.0, bx[i], by[i], bz[i]))
				{
					new rand = random(2)+1;
					if(rand == 1)
					{
				   		GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
				   		ApplyAnimation(playerid, "BOMBER","BOM_Plant_Loop",4.0,0,0,0,0,1000);
						SendClientMessage(playerid, COLOR_WHITE, "[Info:] You have defused the bomb safely");
						format(string, sizeof(string), "%s successfully cuts the wires and defuses the bomb", giveplayer);
						ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
						TextDrawHideForPlayer(i, Meter1[playerid]);
						TextDrawHideForPlayer(i, Meter2[playerid]);
						TextDrawHideForPlayer(i, Meter3[playerid]);
						KillTimer(UpdateMeterTimer[playerid]);
						DestroyObject(i, C4[playerid]);
						Planted[playerid] = 0;
					}
					else
					{
						GameTextForPlayer(playerid, "~r~Wrong Wire!", 2000, 1);
						CreateExplosion(bx[playerid], by[playerid], bz[playerid], 6, ExplosionRadius);
						TextDrawHideForPlayer(i, Meter1[playerid]);
						TextDrawHideForPlayer(i, Meter2[playerid]);
						TextDrawHideForPlayer(i, Meter3[playerid]);
						KillTimer(UpdateMeterTimer[playerid]);
						DestroyObject(C4[playerid]);
						Planted[playerid] = 0;
					}
	  			}
				else
				{
					SendClientMessage(playerid, COLOR_GREY, "[Error:] You are not in range of a bomb");
				}
			}
		}// not connected
		return 1;
	}
Reply
#2

what are you trying to do? the defure CMD has a C4 var but i dont see it set anywhere in plantbomb cmd.
Reply
#3

well when I try to use the defuse command I try to fix as many of the errors but the bx and bombx etc pop up as errors or will and am I trying to combine that /defuse into the /plantbomb but I am having difficulty with it since I remove C4 and replace it with destroypickup then the timer becomes a problem and says it is to many arguments. Same with the bx/bombx problem..
Reply
#4

notsure if it will work but here

pawn Код:
if (strcmp(cmd, "/plantbomb", true) ==0 )
        {
            if(PlayerInfo[playerid][pBomb] < 1)
            {
                SendClientMessage(playerid, COLOR_BLUE, "You don't have bombs");
                return 1;
            }
            if(IsPlayerInAnyVehicle(playerid))
            {
                PlayerInfo[playerid][pBomb] = 0;
                TogglePlayerControllable(playerid, 0);
                SetTimerEx("BombTimer2", 5000, 0, "d", playerid);
                format(string, sizeof(string), "%s begins to plant a bomb.", GetPlayerNameEx(playerid));
                ProxDetector(5.0, playerid, string,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
                return 1;
            }
            PlayerInfo[playerid][pBomb] = 0;
            TogglePlayerControllable(playerid, 0);
            ApplyAnimation(playerid, "BOMBER","BOM_Plant_Loop",4.0,1,0,0,0,0);
            SetTimerEx("BombTimer2", 5000, 0, "d", playerid);
            format(string, sizeof(string), "%s begins to plant a bomb.", GetPlayerNameEx(playerid));
            ProxDetector(5.0, playerid, string,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
            return 1;
        }

forward BombTimer2(playerid);
public BombTimer2(playerid)
{
    GetPlayerPos(playerid, bombx, bomby, bombz);
    TheBomb[playerid] = CreatePickup(1252, 1, bombx, bomby, bombz, -1);
    TogglePlayerControllable(playerid, 1);
    ClearAnimations(playerid);
    SendClientMessage(playerid, COLOR_SPRINGGREEN, "The Bomb explodes in 20 Seconds! RUN!");
    BombExplosion[playerid] = 20;
    BombingTime2[playerid] = SetTimerEx("BombTimer3", 1000, 1, "d", playerid);
    return 1;
}

forward BombTimer3(playerid);
public BombTimer3(playerid)
{
    new string[128];
    if(BombExplosion[playerid] == 0)
    {
        CreateExplosion(bombx, bomby, bombz, 6, 100.0);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerInRangeOfPoint(i, 100.0, bombx, bomby, bombz))
            {

                SendClientMessage(i, COLOR_SPRINGGREEN, "You have been caughten up in the bomb explosion");
                ApplyAnimation(i, "WUZI", "CS_Dead_Guy", 4.0, 0, 0, 0, 0, 0); // Dead Crawling
                GivePlayerHealth(i, -90);
                DestroyPickup(TheBomb[i]);
                ApplyAnimation(i, "WUZI", "CS_Dead_Guy", 4.0, 0, 0, 0, 0, 0); // Dead Crawling
            }
        }
        KillTimer(BombingTime2[playerid]);
        return 1;
    }
    PlayerPlaySound(playerid, 1132, bombx, bomby, bombz);
    BombExplosion[playerid] --;
    format(string, 256, "~g~~>~Time Left~w~ - %d~<~", BombExplosion[playerid]);
    GameTextForPlayer(playerid, string, 1000, 4);
    return 1;
}

forward BombTimer(playerid);
public BombTimer(playerid)
{
    new string[128];
    if(BombTime[playerid] == 0)
    {
        KillTimer(BombingTime[playerid]);
        TogglePlayerControllable(playerid, 1);
        ClearAnimations(playerid);
        SendClientMessage(playerid, COLOR_SPRINGGREEN, "You have made yourself a bomb!");
        PlayerInfo[playerid][pBomb] = 1;
        PlayerInfo[playerid][pBombMats] = 0;
        return 1;
    }
    BombTime[playerid] --;
    format(string, 256, "~r~~>~Time Left~w~ - %d~<~", BombTime[playerid]);
    GameTextForPlayer(playerid, string, 1000, 4);
    return 1;
}




if(strcmp(cmd, "/defuse", true) == 0)
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(PlayerInfo[playerid][pFaction] != 255 && DynamicFactions[PlayerInfo[playerid][pFaction]][fType] != 1)
                {
                    SendClientMessage(playerid, COLOR_GREY, "[Error:] Invalid faction");
                    return 1;
                }
                if(CopOnDuty[playerid] == 0)
                {
                    SendClientMessage(playerid, COLOR_GREY, "[Error:] You are not on duty");
                    return 1;
                }
                if(IsPlayerInAnyVehicle(playerid))
                {
                    return 1;
                }
                new Float:bx[MAX_PLAYERS], Float:by[MAX_PLAYERS], Float:bz[MAX_PLAYERS];
                GetObjectPos(TheBomb[i], bx[i], by[i], bz[i]);
                if(IsPlayerInRangeOfPoint(playerid, 2.0, bx[i], by[i], bz[i]))
                {
                    new rand = random(2)+1;
                    if(rand == 1)
                    {
                        GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                        ApplyAnimation(playerid, "BOMBER","BOM_Plant_Loop",4.0,0,0,0,0,1000);
                        SendClientMessage(playerid, COLOR_WHITE, "[Info:] You have defused the bomb safely");
                        format(string, sizeof(string), "%s successfully cuts the wires and defuses the bomb", giveplayer);
                        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                        TextDrawHideForPlayer(i, Meter1[playerid]);
                        TextDrawHideForPlayer(i, Meter2[playerid]);
                        TextDrawHideForPlayer(i, Meter3[playerid]);
                        KillTimer(BombTimer3[i]);
                        BombTimer3[i]=0;
                        BombExplosion=0;
                        DestroyObject(i, TheBomb[i]);
                        Planted[playerid] = 0;
                        KillTimer(UpdateMeterTimer[playerid]);
                    }
                    else
                    {
                        GameTextForPlayer(playerid, "~r~Wrong Wire!", 2000, 1);
                        CreateExplosion(bx[playerid], by[playerid], bz[playerid], 6, ExplosionRadius);
                        TextDrawHideForPlayer(i, Meter1[playerid]);
                        TextDrawHideForPlayer(i, Meter2[playerid]);
                        TextDrawHideForPlayer(i, Meter3[playerid]);
                        KillTimer(UpdateMeterTimer[playerid]);
                        DestroyObject(TheBomb[i]);
                        Planted[playerid] = 0;
                        KillTimer(BombingTime2[i]);
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "[Error:] You are not in range of a bomb");
                }
            }
        }// not connected
        return 1;
    }
changed some vars here and there
Reply
#5

Quote:

C:\Users\Owner\Desktop\S)\.pwn(5370) : error 028: invalid subscript (not an array or too many subscripts): "BombTimer3"
C:\Users\Owner\Desktop\\.pwn(5370) : warning 215: expression has no effect
C:\Users\Owner\Desktop\)\.pwn(5370) : error 001: expected token: ";", but found "]"
C:\Users\Owner\Desktop\)\.pwn(5370) : error 029: invalid expression, assumed zero
C:\Users\Owner\Desktop\)\.pwn(5370) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

.... See what I mean?
Reply
#6

wups.... change all the BombTimer3[i] to BombingTime2[i]
Reply
#7

Ok I figured out how to get it to work I just need to make sure it disables the explosion problem... Any idea's?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)