Firework system
#1

This is my code: /lightfw
pawn Код:
CMD:lightfw(playerid, params[])
{
    new distance;
    if(AllowedFirework[DrawDistance] == 0) distance = 15;
    if(AllowedFirework[DrawDistance] == 1) distance = 22;
    if(AllowedFirework[DrawDistance] == 2) distance = 30;
    if(!strlen(params))
    {
        SendClientMessage(playerid, COLOR_RED, "[ERROR] "GREY" /lightfw [Type]");
        SendClientMessage(playerid, COLOR_RED, "[ERROR] "GREY"Types: firecracker, crackerroll, firerocket1, firerocket2, fountain1, fountain2, fountain3, rocketbox");
        return 1;
    }
    if(strcmp("firerocket2", params, true, 11) == 0)
    {
            if(firerockettime[playerid] == 0)
            {
                new Float:X, Float:Y,Float:Z;
                firerockettime[playerid] = 2;
                new string[128];
                new sendername[MAX_PLAYER_NAME];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "<> %s lights up a fire rocket.", sendername);
                ProxDetector(15.0, playerid, string, COLOR_WHITE,COLOR_WHITE,COLOR_WHITE,COLOR_WHITE,COLOR_WHITE);
                GetPlayerPos(playerid,X,Y,Z);
                GetXYInFrontOfPlayer(playerid, X,Y, distance);
                Firerocket[playerid] = CreateObject(354, X,Y,(Z), 0, 0, 0);
                rocketsmoke[playerid] = CreateObject(2780, X,Y,(Z), 0, 0, 0);
                MoveObject(Firerocket[playerid], X, Y, Z+50, 15);
                MoveObject(rocketsmoke[playerid], X, Y, Z+50, 15);
                SetTimerEx("FirerocketTime", 3000, 0, "i", playerid);
                return 1;
            }
            else return SendClientMessage(playerid, COLOR_RED, "[ERROR] "GREY"You have already lighted a firework!");
    }
    if(strcmp("fountain1", params, true, 9) == 0)
    {
        `   if(Fountain1Time[playerid] == 0 && Fountain2Time[playerid] == 0 && Fountain3Time[playerid] == 0) // LINE 3795
^^ LINE 3795
            {
                new Float:X, Float:Y,Float:Z;
                Fountain1Time[playerid] = 1;
                new string[128];
                new sendername[MAX_PLAYER_NAME];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "<> %s places a Firework Fountain on the ground.", sendername);
                ProxDetector(15.0, playerid, string, COLOR_WHITE,COLOR_WHITE,COLOR_WHITE,COLOR_WHITE,COLOR_WHITE);
                GetPlayerPos(playerid,X,Y,Z);
                GetXYInFrontOfPlayer(playerid, X,Y, 15);
                FTX[playerid] = X;
                FTY[playerid] = Y;
                FTZ[playerid] = (Z-1.0);
                Fountain[playerid] = CreateObject(354, X,Y,(Z-1.0), 0, 0, 0);
                FountainSmoke[playerid] = CreateObject(2780, X,Y,(Z-1.0), 0, 0, 0);
                SetTimerEx("FountainTimer", 3000, 0, "i", playerid);
                return 1;
            }
            else return SendClientMessage(playerid, COLOR_RED, "[ERROR] "GREY"You have already lighted a firework!");
    }
    if(strcmp("fountain3", params, true, 9) == 0)
    {
            if(Fountain1Time[playerid] == 0 && Fountain2Time[playerid] == 0 && Fountain3Time[playerid] == 0)
            {
                new Float:X, Float:Y,Float:Z;
                Fountain3Time[playerid] = 1;
                new string[128];
                new sendername[MAX_PLAYER_NAME];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "<> %s places a Firework Fountain on the ground.", sendername);
                ProxDetector(15.0, playerid, string, COLOR_WHITE,COLOR_WHITE,COLOR_WHITE,COLOR_WHITE,COLOR_WHITE);
                GetPlayerPos(playerid,X,Y,Z);
                GetXYInFrontOfPlayer(playerid, X,Y, 15);
                FTX[playerid] = X;
                FTY[playerid] = Y;
                FTZ[playerid] = (Z-1.0);
                Fountain[playerid] = CreateObject(354, X,Y,(Z-1.0), 0, 0, 0);
                FountainSmoke[playerid] = CreateObject(2780, X,Y,(Z-1.0), 0, 0, 0);
                SetTimerEx("FountainTimer", 3000, 0, "i", playerid);
                return 1;
            }
            else return SendClientMessage(playerid, COLOR_RED, "[ERROR] "GREY"You have already lighted a firework!");
    }
    if(strcmp("rocketbox", params, true, 9) == 0)
    {
            if(RocketBoxTime[playerid] == 0)
            {
                new Float:X, Float:Y,Float:Z;
                RocketBoxTime[playerid] = 1;
                new string[128];
                new sendername[MAX_PLAYER_NAME];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "<> %s places a Rocketbox on the ground.", sendername);
                ProxDetector(15.0, playerid, string, COLOR_WHITE,COLOR_WHITE,COLOR_WHITE,COLOR_WHITE,COLOR_WHITE);
                GetPlayerPos(playerid,X,Y,Z);
                GetXYInFrontOfPlayer(playerid, X,Y, distance);
                RBX[playerid] = X;
                RBY[playerid] = Y;
                RBZ[playerid] = (Z-1.0);
                RocketBox[playerid] = CreateObject(354, X,Y,(Z-1.0), 0, 0, 0);
                RocketBoxSmoke[playerid] = CreateObject(2780, X,Y,(Z-1.0), 0, 0, 0);
                SetTimerEx("RocketBoxTimer", 3000, 0, "i", playerid);
                return 1;
            }
            else return SendClientMessage(playerid, COLOR_RED, "[ERROR] "GREY"You have already lighted a firework!");
    }
    else return SendClientMessage(playerid, COLOR_RED, "[ERROR] "GREY"Usage: /lightfirework [Type]");
}
Now, I got these errors <.<
Код:
C:\Users\Matt\Desktop\samp03z_svr_R1_win32\gamemodes\stunting.pwn(3795) : error 029: invalid expression, assumed zero
C:\Users\Matt\Desktop\samp03z_svr_R1_win32\gamemodes\stunting.pwn(3795) : warning 215: expression has no effect
C:\Users\Matt\Desktop\samp03z_svr_R1_win32\gamemodes\stunting.pwn(3795) : error 001: expected token: ";", but found "if"
Line 3795: if(Fountain1Time[playerid] == 0 && Fountain2Time[playerid] == 0 && Fountain3Time[playerid] == 0)

-- You can also find the other lines below if(strcmp,"firerocket2"....)
Reply
#2

Distance is float, so:

pawn Код:
new Float:distance;
There is a ` before if(Fountain1Time[playerid] == 0....

Use else if statement after checking the first parameter.
Reply
#3

pawn Код:
CMD:lightfw(playerid, params[])
{
    new distance;
    if(AllowedFirework[DrawDistance] == 0) distance = 15;
    if(AllowedFirework[DrawDistance] == 1) distance = 22;
    if(AllowedFirework[DrawDistance] == 2) distance = 30;
    if(!strlen(params))
    {
        SendClientMessage(playerid, COLOR_RED, "[ERROR] "GREY" /lightfw [Type]");
        SendClientMessage(playerid, COLOR_RED, "[ERROR] "GREY"Types: firecracker, crackerroll, firerocket1, firerocket2, fountain1, fountain2, fountain3, rocketbox");
        return 1;
    }
    if(strcmp("firerocket2", params, true, 11) == 0)
    {
            if(firerockettime[playerid] == 0)
            {
                new Float:X, Float:Y,Float:Z;
                firerockettime[playerid] = 2;
                new string[128];
                new sendername[MAX_PLAYER_NAME];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "<> %s lights up a fire rocket.", sendername);
                ProxDetector(15.0, playerid, string, COLOR_WHITE,COLOR_WHITE,COLOR_WHITE,COLOR_WHITE,COLOR_WHITE);
                GetPlayerPos(playerid,X,Y,Z);
                GetXYInFrontOfPlayer(playerid, X,Y, distance);
                Firerocket[playerid] = CreateObject(354, X,Y,(Z), 0, 0, 0);
                rocketsmoke[playerid] = CreateObject(2780, X,Y,(Z), 0, 0, 0);
                MoveObject(Firerocket[playerid], X, Y, Z+50, 15);
                MoveObject(rocketsmoke[playerid], X, Y, Z+50, 15);
                SetTimerEx("FirerocketTime", 3000, 0, "i", playerid);
                return 1;
            }
            else return SendClientMessage(playerid, COLOR_RED, "[ERROR] "GREY"You have already lighted a firework!");
    }
    if(strcmp("fountain1", params, true, 9) == 0)
    {
            if(Fountain1Time[playerid] == 0 && Fountain2Time[playerid] == 0 && Fountain3Time[playerid] == 0)
            {
                new Float:X, Float:Y,Float:Z;
                Fountain1Time[playerid] = 1;
                new string[128];
                new sendername[MAX_PLAYER_NAME];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "<> %s places a Firework Fountain on the ground.", sendername);
                ProxDetector(15.0, playerid, string, COLOR_WHITE,COLOR_WHITE,COLOR_WHITE,COLOR_WHITE,COLOR_WHITE);
                GetPlayerPos(playerid,X,Y,Z);
                GetXYInFrontOfPlayer(playerid, X,Y, 15);
                FTX[playerid] = X;
                FTY[playerid] = Y;
                FTZ[playerid] = (Z-1.0);
                Fountain[playerid] = CreateObject(354, X,Y,(Z-1.0), 0, 0, 0);
                FountainSmoke[playerid] = CreateObject(2780, X,Y,(Z-1.0), 0, 0, 0);
                SetTimerEx("FountainTimer", 3000, 0, "i", playerid);
                return 1;
            }
            else return SendClientMessage(playerid, COLOR_RED, "[ERROR] "GREY"You have already lighted a firework!");
    }
    if(strcmp("fountain3", params, true, 9) == 0)
    {
            if(Fountain1Time[playerid] == 0 && Fountain2Time[playerid] == 0 && Fountain3Time[playerid] == 0)
            {
                new Float:X, Float:Y,Float:Z;
                Fountain3Time[playerid] = 1;
                new string[128];
                new sendername[MAX_PLAYER_NAME];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "<> %s places a Firework Fountain on the ground.", sendername);
                ProxDetector(15.0, playerid, string, COLOR_WHITE,COLOR_WHITE,COLOR_WHITE,COLOR_WHITE,COLOR_WHITE);
                GetPlayerPos(playerid,X,Y,Z);
                GetXYInFrontOfPlayer(playerid, X,Y, 15);
                FTX[playerid] = X;
                FTY[playerid] = Y;
                FTZ[playerid] = (Z-1.0);
                Fountain[playerid] = CreateObject(354, X,Y,(Z-1.0), 0, 0, 0);
                FountainSmoke[playerid] = CreateObject(2780, X,Y,(Z-1.0), 0, 0, 0);
                SetTimerEx("FountainTimer", 3000, 0, "i", playerid);
                return 1;
            }
            else return SendClientMessage(playerid, COLOR_RED, "[ERROR] "GREY"You have already lighted a firework!");
    }
    if(strcmp("rocketbox", params, true, 9) == 0)
    {
            if(RocketBoxTime[playerid] == 0)
            {
                new Float:X, Float:Y,Float:Z;
                RocketBoxTime[playerid] = 1;
                new string[128];
                new sendername[MAX_PLAYER_NAME];
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "<> %s places a Rocketbox on the ground.", sendername);
                ProxDetector(15.0, playerid, string, COLOR_WHITE,COLOR_WHITE,COLOR_WHITE,COLOR_WHITE,COLOR_WHITE);
                GetPlayerPos(playerid,X,Y,Z);
                GetXYInFrontOfPlayer(playerid, X,Y, distance);
                RBX[playerid] = X;
                RBY[playerid] = Y;
                RBZ[playerid] = (Z-1.0);
                RocketBox[playerid] = CreateObject(354, X,Y,(Z-1.0), 0, 0, 0);
                RocketBoxSmoke[playerid] = CreateObject(2780, X,Y,(Z-1.0), 0, 0, 0);
                SetTimerEx("RocketBoxTimer", 3000, 0, "i", playerid);
                return 1;
            }
            else return SendClientMessage(playerid, COLOR_RED, "[ERROR] "GREY"You have already lighted a firework!");
    }
    else return SendClientMessage(playerid, COLOR_RED, "[ERROR] "GREY"Usage: /lightfirework [Type]");
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)