limit fireworks placed
#1

Код:
CMD:placefirework(playerid, params[])
{
	if(GetPVarInt(playerid, "IsInArena") >= 0)
	{
		SendClientMessageEx(playerid, COLOR_WHITE, "You can't do this while being in an arena!");
		return 1;
	}
	if(WatchingTV[playerid] != 0) {
        SendClientMessageEx(playerid, COLOR_GREY, "You can not do this while watching TV!");
        return 1;
    }
	if(GetPVarInt(playerid, "Injured") == 1 || GetPVarInt(playerid, "Hospital") == 1 || IsPlayerInAnyVehicle(playerid))
	{
		SendClientMessageEx(playerid, COLOR_WHITE, "You can't do this right now.");
		return 1;
	}
	//if(RocketExplosions[playerid] != 0)
	//{
	 //   SendClientMessageEx(playerid, COLOR_WHITE, "You are already using another firework!");
	//	return 1;
	//}
	if (PlayerInfo[playerid][pVW] != 0 || PlayerInfo[playerid][pInt] != 0)
	{
	    SendClientMessageEx(playerid, COLOR_WHITE, "You can't launch fireworks indoors!");
		return 1;
	}
	if(PlayerInfo[playerid][pFirework] > 0 || PlayerInfo[playerid][pAdmin] >= 4)
	{
	    if (PlayerInfo[playerid][pAdmin] < 4)
	    {
	    	PlayerInfo[playerid][pFirework]--;
	    }
		new string[128];
		format(string, sizeof(string), "%s has placed a firework which will go off in 15 seconds!", GetPlayerNameEx(playerid));
	    ProxDetector(30.0, playerid, string, COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
	    new Float:x, Float:y, Float:z, Float:a;
	    GetPlayerPos(playerid, x, y, z);
	    GetPlayerFacingAngle(playerid, a);
	    ApplyAnimation(playerid,"BOMBER","BOM_Plant_Crouch_In", 4.0, 0, 0, 0, 0, 0, 1);
	    x += (2 * floatsin(-a, degrees));
    	y += (2 * floatcos(-a, degrees));
	    Rocket[playerid] = CreateDynamicObject(3786, x, y, z, 0, 90, 0);
	    RocketLight[playerid] = CreateDynamicObject(354, x, y, z + 1, 0, 0, 0);
		RocketSmoke[playerid] = CreateDynamicObject(18716, x, y, z - 4, 0, 0, 0);
	    SetPVarFloat(playerid,"fxpos",x);
  		SetPVarFloat(playerid,"fypos",y);
  		SetPVarFloat(playerid,"fzpos",z);
  		RocketExplosions[playerid] = 0;
  		SetTimerEx("Firework", 10000, 0, "ii", playerid, TYPE_COUNTDOWN);
	}
	else
	{
		SendClientMessageEx(playerid, COLOR_GRAD1, "You don't have any fireworks!");
	}
	return 1;
}
how can i define it so a player can place 1 per time
Reply
#2

pawn Код:
if(FireworkTotal == MAX_LAUNCH)
                {
                    SendClientMessage(playerid, COLOR_WHITE, "You can only place a firework once a time!");
                        return 1;
                }
                if(Fired == 1)
                {
                    SendClientMessage(playerid, COLOR_WHITE, "Please wait til your firework done.");
                        return 1;
                }
Reply
#3

Or you can make an variable or Pvar that, the firework is placed.

new Firework_Placed[MAX_PLAYERS] = 0;

to check use:

Код:
if(Firework_Placed[playerid] == 1)//If is placed
{
}
Oh and you must set the variable to one if you decide to use this.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)