How to remove These errors from my 1 cmd?? (rep+)
#1

===> I did this for Airstrike:
pawn Код:
COMMAND:airstrike(playerid, params[])
{
    if(GetPlayerScore(playerid) >= 2000)
    {
        return SendClientMessage(playerid, 0xFF0000FF, "You dont have enough score, you need 2000 score");

    }
    else
    {
        new float:X, float:Y, float:Z,
        GetPlayerPos(playerid, X, Y, Z);
        SetTimer("5 seconds for the bomb to drop", 5000, false);
        CreateExplosion(X, Y, Z, 7, 20.0);
        SendClientMessage(playerid, 0xFF0000FF, "Bomb was dropped!");
    }
    return 1;
}
===> And i am getting these errors and warnings.
pawn Код:
D:\Game\SA-MP Files\Dark Wars\gamemodes\Wars.pwn(1095) : warning 219: local variable "GetPlayerPos" shadows a variable at a preceding level
D:\Game\SA-MP Files\Dark Wars\gamemodes\Wars.pwn(1095) : error 001: expected token: ";", but found "("
D:\Game\SA-MP Files\Dark Wars\gamemodes\Wars.pwn(1095) : warning 215: expression has no effect
D:\Game\SA-MP Files\Dark Wars\gamemodes\Wars.pwn(1097) : warning 213: tag mismatch
D:\Game\SA-MP Files\Dark Wars\gamemodes\Wars.pwn(1097) : warning 213: tag mismatch
D:\Game\SA-MP Files\Dark Wars\gamemodes\Wars.pwn(1097) : warning 213: tag mismatch
D:\Game\SA-MP Files\Dark Wars\gamemodes\Wars.pwn(1095) : warning 203: symbol is never used: "GetPlayerPos"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
Reply
#2

Код:
COMMAND:airstrike(playerid, params[])
{
    if(GetPlayerScore(playerid) >= 2000)
    {
        return SendClientMessage(playerid, 0xFF0000FF, "You dont have enough score, you need 2000 score");

    }
    else
    {
        new Float:X, Float:Y, Float:Z;
        GetPlayerPos(playerid, X, Y, Z);
        SetTimer("5 seconds for the bomb to drop", 5000, false);
        CreateExplosion(X, Y, Z, 7, 20.0);
        SendClientMessage(playerid, 0xFF0000FF, "Bomb was dropped!");
    }
    return 1;
}
Is there any error now?
Reply
#3

Let's go through your error list:
Код:
D:\Game\SA-MP Files\Dark Wars\gamemodes\Wars.pwn(1095) : warning 219: local variable "GetPlayerPos" shadows a variable at a preceding level
D:\Game\SA-MP Files\Dark Wars\gamemodes\Wars.pwn(1095) : error 001: expected token: ";", but found "("
D:\Game\SA-MP Files\Dark Wars\gamemodes\Wars.pwn(1095) : warning 215: expression has no effect
D:\Game\SA-MP Files\Dark Wars\gamemodes\Wars.pwn(1097) : warning 213: tag mismatch
D:\Game\SA-MP Files\Dark Wars\gamemodes\Wars.pwn(1097) : warning 213: tag mismatch
D:\Game\SA-MP Files\Dark Wars\gamemodes\Wars.pwn(1097) : warning 213: tag mismatch
D:\Game\SA-MP Files\Dark Wars\gamemodes\Wars.pwn(1095) : warning 203: symbol is never used: "GetPlayerPos"
Pawn compiler 3.2.3664          Copyright © 1997-2006, ITB CompuPhase


1 Error.
Код:
D:\Game\SA-MP Files\Dark Wars\gamemodes\Wars.pwn(1095) : warning 219: local variable "GetPlayerPos" shadows a variable at a preceding level
This means you've already got a variable named the same, outside the callback. Like this:
pawn Код:
new var;
public callback()
{
  new var; // two variables called 'var'
}
It can be fixed by naming your vars something else:
pawn Код:
new float:tX, float:tY, float:tZ,
Код:
D:\Game\SA-MP Files\Dark Wars\gamemodes\Wars.pwn(1095) : error 001: expected token: ";", but found "("
D:\Game\SA-MP Files\Dark Wars\gamemodes\Wars.pwn(1095) : warning 215: expression has no effect
D:\Game\SA-MP Files\Dark Wars\gamemodes\Wars.pwn(1095) : warning 203: symbol is never used: "GetPlayerPos"
This means you forgot a ; somewhere. In this case, it's here:
pawn Код:
new float:tX, float:tY, float:tZ,
It should be a ';' instead of just a ',' (at the end).
pawn Код:
new float:tX, float:tY, float:tZ;
This also fixes the 'expression has no effect' and 'symbol is never used' warning.

Код:
D:\Game\SA-MP Files\Dark Wars\gamemodes\Wars.pwn(1097) : warning 213: tag mismatch
D:\Game\SA-MP Files\Dark Wars\gamemodes\Wars.pwn(1097) : warning 213: tag mismatch
D:\Game\SA-MP Files\Dark Wars\gamemodes\Wars.pwn(1097) : warning 213: tag mismatch
This means you're using the wrong variable tag, for example using an integer where you're supposed to use a float. In this case, you need to use Float:, not float: (Notice the capital F):
pawn Код:
new Float:tX, Float:tY, Float:tZ;

Your new code should look like:

pawn Код:
COMMAND:airstrike(playerid, params[])
{
    if(GetPlayerScore(playerid) >= 2000)
    {
        return SendClientMessage(playerid, 0xFF0000FF, "You dont have enough score, you need 2000 score");

    }
    else
    {
        new Float:tX, Float:tY, Float:tZ;
        GetPlayerPos(playerid, tX, tY, tZ);
        SetTimer("5 seconds for the bomb to drop", 5000, false);
        CreateExplosion(tX, tY, tZ, 7, 20.0);
        SendClientMessage(playerid, 0xFF0000FF, "Bomb was dropped!");
    }
    return 1;
}
Reply
#4

Sorry dude I forgot some things like ; and blabla this was made in a minute.
Reply
#5

I'm not sure if you can use SetTimer like that because its suposse to call a function in the first parameter
Reply
#6

pawn Код:
SetTimer("5 seconds for the bomb to drop", 5000, false);
^ That should be, for example, :

pawn Код:
SetTimer("5SecondsToDrop", 5000, false);
You can't use blank spaces, since your timer will become a callback!
Reply
#7

=> I did this but even i have 0 score it drop bomb. And there is not timer. As Soon as i type /airstrike it blast. And I also want like if player has cash less then 10000 then he can't do airstike... Please i beg u help me!!!!
pawn Код:
COMMAND:airstrike(playerid, params[])
{
    if(GetPlayerScore(playerid) >= 2000)
    {
        return SendClientMessage(playerid, 0xFF0000FF, "You dont have enough score, you need 2000 score");

    }
    else
    {
        new Float:tX, Float:tY, Float:tZ;
        GetPlayerPos(playerid, tX, tY, tZ);
        GivePlayerMoney(playerid,-10000);
        SetTimer("5 Seconds To Drop", 5000, false);
        CreateExplosion(tX, tY, tZ, 7, 20.0);
        SendClientMessage(playerid, 0xFF0000FF, "Air Strike Successfully Done!");
    }
    return 1;
}
Reply
#8

pawn Код:
new bomb;
new bombblast;

forward DropBomb(playerid);

COMMAND:airstrike(playerid, params[])
{
    if(GetPlayerScore(playerid) >= 2000) return SendClientMessage(playerid, 0xFF0000FF, "You dont have enough score, you need 2000 score");
    else
    {
        if(GetPlayerMoney(playerid)<10000) return SendClientMessage(playerid,COLOR_RED,"Not enough money!");
        else
        {
          GivePlayerMoney(playerid,-10000);
          bomb=5;
          bombblast = SetTimerEx("DropBomb", 1000, true,"i",playerid);
        }
    }
    return 1;
}
public DropBomb(playerid)
{
   bomb--;
   if(bomb<=-1)
   {
       KillTimer(bombblast);
       new Float:tX, Float:tY, Float:tZ;
       GetPlayerPos(playerid, tX, tY, tZ);
       CreateExplosion(tX, tY, tZ, 7, 20.0);
       SendClientMessage(playerid, 0xFF0000FF, "Air Strike Successfully Done!");
   }
 return 1;
}
Replacce ther whole code with what I gave you...
Reply
#9

pawn Код:
COMMAND:airstrike(playerid, params[])
{
    if(GetPlayerScore(playerid) < 2000) return SendClientMessage(playerid, 0xFF0000FF, "You don't have enough score, you need 2000 score");
    if(GetPlayerMoney(playerid) < 10000) return SendClientMessage(playerid, 0xFF0000FF, "You don't have enough money.");
    GivePlayerMoney(playerid,-10000);
    SendClientMessage(playerid, 0xFF0000FF, "Air Strike Successfully Done!");
    SetTimerEx("ExplodeBomb", 5000, false, "i", playerid);
    return 1;
}
forward ExplodeBomb(playerid);
public ExplodeBomb(playerid)
{
    new Float: Pos[3];
    GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
    CreateExplosion(Pos[0], Pos[1], Pos[2], 7, 20.0);
    return 1;
}
@ why don't you use a timer set to 5 seconds, wtf?

@@ cjgogo, your code won't work, because the player that uses the command should have less than 2000 score.
Reply
#10

SetTimer may bug,use SetTimerEx,iOmar :P,I mean my code ,but fordawinzz code may also work,choose :P
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)