Help Something Wrong
#1

i created basic script for plant bomb but problem is player can use /plantbomb somewhere and can spam this command i want this command only can used at cordinates for plant and it same with /defusebomb
pawn Код:
#include <a_samp>
     
    #define T1 0
    #define C1 1
     
    #define COLOR_RED 0xFF0000AA
    #define COLOR_BLUE 0x0000BBAA
     
    new gTeam[MAX_PLAYERS];
    new PlantedBomb[MAX_PLAYERS];
     
    public OnGameModeInit()
    {
            SetGameModeText("Blank Script");
            return 1;
    }
     
    public OnGameModeExit()
    {
            return 1;
    }
     
    public OnPlayerRequestClass(playerid, classid)
    {
            SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
            SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
            SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
            return 1;
    }
     
    public OnPlayerConnect(playerid)
    {
            return 1;
    }
     
    public OnPlayerDisconnect(playerid, reason)
    {
            return 1;
    }
     
    public OnPlayerSpawn(playerid)
    {
            return 1;
    }
     
    public OnPlayerDeath(playerid, killerid, reason)
    {
            return 1;
    }
     
    public OnVehicleSpawn(vehicleid)
    {
            return 1;
    }
     
    public OnVehicleDeath(vehicleid, killerid)
    {
            return 1;
    }
     
    public OnPlayerText(playerid, text[])
    {
            return 1;
    }
     
    public OnPlayerCommandText(playerid, cmdtext[])
    {
            if (strcmp("/plantbomb", cmdtext, true, 10) == 0)
            {
                if(gTeam[playerid] == T1)
                {
                       if(IsPlayerInRangeOfPoint(playerid,2.0,212.9239,1820.3402,6.4216))
                   if(PlantedBomb[T1] == 1) return SendClientMessage(playerid,COLOR_RED,"The bomb is already planted!");
                   if(gTeam[playerid] == C1) return SendClientMessage(playerid,COLOR_RED,"Only the terrorists can plant the bomb!");
                   PlantedBomb [T1] ++;
                   GameTextForAll("~r~Bomb has been planted!",3000,5);
               SetTimer("Explosion",300000,0);
                }
                    else
                    {
                        SendClientMessage(playerid,COLOR_RED,"You are not in the place for planting the bomb");
                    }
                   
                    return 1;
            }
            if (strcmp("/defusebomb", cmdtext, true, 10) == 0)
            {
                if(gTeam[playerid] == C1)
                {
                    if(IsPlayerInRangeOfPoint(playerid,2.0,213.3134,1825.4974,6.4141))
                    if(PlantedBomb[T1] == 0) return SendClientMessage(playerid,COLOR_RED,"The bomb is not planted!");
                    if(gTeam[playerid] == T1) return SendClientMessage(playerid,COLOR_RED,"Only the cops can defuse the bombs, your job is to plant them!");
                    SendClientMessage(playerid,COLOR_BLUE,"You are defusing a bomg, please wait.");
                    SetTimer("Defusion",10000,0);
                }
                    else
                    {
                        SendClientMessage(playerid,COLOR_RED,"You are not in the place for defusing the bomb!");
                    }
            }
            return 0;
    }
    forward Explosion(playerid);
    public Explosion(playerid)
    {
            GameTextForAll("~r~Bomb exploded",3000,5);
            CreateExplosion(212.9239,1820.3402,6.4216,12,20.0);
            GivePlayerMoney(playerid,10000);
            SetPlayerScore(playerid, GetPlayerScore(playerid) + 5);
            return 1;
    }
    forward Defusion(playerid);
    public Defusion(playerid)
    {
            KillTimer(0);
            GameTextForAll("~b~Bomb defused",3000,5);
            GivePlayerMoney(playerid,10000);
            SetPlayerScore(playerid, GetPlayerScore(playerid) + 5);
            return 1;
    }
    public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
    {
            return 1;
    }
     
    public OnPlayerExitVehicle(playerid, vehicleid)
    {
            return 1;
    }
     
    public OnPlayerStateChange(playerid, newstate, oldstate)
    {
            return 1;
    }
     
    public OnPlayerEnterCheckpoint(playerid)
    {
            return 1;
    }
     
    public OnPlayerLeaveCheckpoint(playerid)
    {
            return 1;
    }
     
    public OnPlayerEnterRaceCheckpoint(playerid)
    {
            return 1;
    }
     
    public OnPlayerLeaveRaceCheckpoint(playerid)
    {
            return 1;
    }
     
    public OnRconCommand(cmd[])
    {
            return 1;
    }
     
    public OnPlayerRequestSpawn(playerid)
    {
            return 1;
    }
     
    public OnObjectMoved(objectid)
    {
            return 1;
    }
     
    public OnPlayerObjectMoved(playerid, objectid)
    {
            return 1;
    }
     
    public OnPlayerPickUpPickup(playerid, pickupid)
    {
            return 1;
    }
     
    public OnVehicleMod(playerid, vehicleid, componentid)
    {
            return 1;
    }
     
    public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
    {
            return 1;
    }
     
    public OnVehicleRespray(playerid, vehicleid, color1, color2)
    {
            return 1;
    }
     
    public OnPlayerSelectedMenuRow(playerid, row)
    {
            return 1;
    }
     
    public OnPlayerExitedMenu(playerid)
    {
            return 1;
    }
     
    public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
    {
            return 1;
    }
     
    public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
    {
            return 1;
    }
     
    public OnRconLoginAttempt(ip[], password[], success)
    {
            return 1;
    }
     
    public OnPlayerUpdate(playerid)
    {
            return 1;
    }
     
    public OnPlayerStreamIn(playerid, forplayerid)
    {
            return 1;
    }
     
    public OnPlayerStreamOut(playerid, forplayerid)
    {
            return 1;
    }
     
    public OnVehicleStreamIn(vehicleid, forplayerid)
    {
            return 1;
    }
     
    public OnVehicleStreamOut(vehicleid, forplayerid)
    {
            return 1;
    }
     
    public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
    {
            return 1;
    }
     
    public OnPlayerClickPlayer(playerid, clickedplayerid, source)
    {
            return 1;
    }
Reply
#2

can anyone help?
Reply
#3

You need brackets here:
pawn Код:
if(IsPlayerInRangeOfPoint(playerid,2.0,212.9239,1820.3402,6.4216))
                   if(PlantedBomb[T1] == 1) return SendClientMessage(playerid,COLOR_RED,"The bomb is already planted!");
                   if(gTeam[playerid] == C1) return SendClientMessage(playerid,COLOR_RED,"Only the terrorists can plant the bomb!");
                   PlantedBomb [T1] ++;
                   GameTextForAll("~r~Bomb has been planted!",3000,5);
               SetTimer("Explosion",300000,0);
                }
                    else
                    {
                        SendClientMessage(playerid,COLOR_RED,"You are not in the place for planting the bomb");
                    }
And same at the /defusebomb command, covering the other stuff inbetween the "if" and "else".
Alternatively, this is easier:
pawn Код:
if(!IsPlayerInRangeOfPoint(playerid,2.0,212.9239,1820.3402,6.4216)) return SendClientMessage(playerid,COLOR_RED,"You are not in the place for planting the bomb");
                   if(PlantedBomb[T1] == 1) return SendClientMessage(playerid,COLOR_RED,"The bomb is already planted!");
                   if(gTeam[playerid] == C1) return SendClientMessage(playerid,COLOR_RED,"Only the terrorists can plant the bomb!");
                   PlantedBomb [T1] ++;
                   GameTextForAll("~r~Bomb has been planted!",3000,5);
               SetTimer("Explosion",300000,0);
                    }
Reply
#4

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
You need brackets here:
pawn Код:
if(IsPlayerInRangeOfPoint(playerid,2.0,212.9239,1820.3402,6.4216))
                   if(PlantedBomb[T1] == 1) return SendClientMessage(playerid,COLOR_RED,"The bomb is already planted!");
                   if(gTeam[playerid] == C1) return SendClientMessage(playerid,COLOR_RED,"Only the terrorists can plant the bomb!");
                   PlantedBomb [T1] ++;
                   GameTextForAll("~r~Bomb has been planted!",3000,5);
               SetTimer("Explosion",300000,0);
                }
                    else
                    {
                        SendClientMessage(playerid,COLOR_RED,"You are not in the place for planting the bomb");
                    }
And same at the /defusebomb command, covering the other stuff inbetween the "if" and "else".
Alternatively, this is easier:
pawn Код:
if(!IsPlayerInRangeOfPoint(playerid,2.0,212.9239,1820.3402,6.4216)) return SendClientMessage(playerid,COLOR_RED,"You are not in the place for planting the bomb");
                   if(PlantedBomb[T1] == 1) return SendClientMessage(playerid,COLOR_RED,"The bomb is already planted!");
                   if(gTeam[playerid] == C1) return SendClientMessage(playerid,COLOR_RED,"Only the terrorists can plant the bomb!");
                   PlantedBomb [T1] ++;
                   GameTextForAll("~r~Bomb has been planted!",3000,5);
               SetTimer("Explosion",300000,0);
                    }
i fixed errors but again the same problem helpp
Reply
#5

I didn't test it or anything, that was just an example.
What i meant is remove "else", and change the "if" so it has a ! like
pawn Код:
if(!IsPlayerInRangeOfPoint(playerid,2.0,212.9239,1820.3402,6.4216))
This will detect if the player is NOT in range of point.
And then make it do what you want, like send a client message.
pawn Код:
if(!IsPlayerInRangeOfPoint(playerid,2.0,212.9239,1820.3402,6.4216)) return SendClientMessage(playerid,COLOR_RED,"You are not in the place for planting the bomb");
The script i gave you probably missed a bracket somewhere, i got confused by your indentation.
Reply
#6

is now ok?

Quote:

#include <a_samp>

#define T1 0
#define C1 1

#define COLOR_RED 0xFF0000AA
#define COLOR_BLUE 0x0000BBAA
#define SCM

new gTeam[MAX_PLAYERS];
new PlantedBomb[MAX_PLAYERS];

public OnGameModeInit()
{
SetGameModeText("Blank Script");
return 1;
}

public OnGameModeExit()
{
return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}

public OnPlayerConnect(playerid)
{
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
return 1;
}

public OnPlayerSpawn(playerid)
{
return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}

public OnVehicleSpawn(vehicleid)
{
return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}

public OnPlayerText(playerid, text[])
{
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/plantbomb", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid,2.0,212.9239,18 20.3402,6.4216))
if(PlantedBomb[T1] == 1) return SendClientMessage(playerid,COLOR_RED,"The bomb is already planted!");
if(gTeam[playerid] == C1) return SendClientMessage(playerid,COLOR_RED,"Only the terrorists can plant the bomb!");
PlantedBomb [T1] ++;
GameTextForAll("~r~Bomb has been planted!",3000,5);
SetTimer("Explosion",300000,0);
}

if (strcmp("/defusebomb", cmdtext, true, 10) == 0)
{
if(!IsPlayerInRangeOfPoint(playerid,2.0,212.9239,1 820.3402,6.4216)) return SendClientMessage(playerid,COLOR_RED,"You are not in the place for planting the bomb");
if(PlantedBomb[T1] == 1) return SendClientMessage(playerid,COLOR_RED,"The bomb is already planted!");
if(gTeam[playerid] == C1) return SendClientMessage(playerid,COLOR_RED,"Only the terrorists can plant the bomb!");
PlantedBomb [T1] ++;
GameTextForAll("~r~Bomb has been planted!",3000,5);
SetTimer("Explosion",300000,0);
}


return 0;
}
forward Explosion(playerid);
public Explosion(playerid)
{
GameTextForAll("~r~Bomb exploded",3000,5);
CreateExplosion(212.9239,1820.3402,6.4216,12,20.0) ;
GivePlayerMoney(playerid,10000);
SetPlayerScore(playerid, GetPlayerScore(playerid) + 5);
return 1;
}
forward Defusion(playerid);
public Defusion(playerid)
{
KillTimer(0);
GameTextForAll("~b~Bomb defused",3000,5);
GivePlayerMoney(playerid,10000);
SetPlayerScore(playerid, GetPlayerScore(playerid) + 5);
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}

public OnRconCommand(cmd[])
{
return 1;
}

public OnPlayerRequestSpawn(playerid)
{
return 1;
}

public OnObjectMoved(objectid)
{
return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}

public OnPlayerExitedMenu(playerid)
{
return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}

public OnPlayerUpdate(playerid)
{
return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)