Bombing vehicles
#1

Hello, im creating a vehicle bomb system and everything works except a thing, the bomb explosion.

I have the cmd: /bomb to place a bomb if you're in a vehicle:

pawn Код:
CMD:bomb(playerid, params[])
{
if(pInfo[playerid][Skill] == 2)
{
if(pInfo[playerid][Logged] == 0) return SCM(playerid,0x0080C0FF,"Please login before using this command.");
if(pInfo[playerid][Jailed] == 1) return SCM(playerid,0xFF0000FF,"You can't use this command in jail.");
if(pSpawned[playerid] == 0) return SCM(playerid, COLOR_LIGHTBLUE, "Please spawn before doing any action.");
if(pAlive[playerid] == 0) return SCM(playerid, COLOR_LIGHTBLUE, "You can't use this command if you are dead.");
if(pInfo[playerid][Bombs] == 0) return SCM(playerid,0xFF0000FF,"You dont have any bombs left, you can buy some at 24/7.");
if(!IsPlayerInAnyVehicle(playerid)) return SCM(playerid, 0xF60000AA, "You must be in a vehicle to plant a bomb.");
if(GetPVarInt(playerid,"PlantBomb")>GetTickCount())return SendClientMessage(playerid,0xFF0000FF,"Please wait 5 minutes before planting a bomb again.");
new crand = random(120);
if(crand <= 53)
{
SetPVarInt(playerid,"PlantBomb",GetTickCount()+300000);
SCM(playerid,0x15FF00FF,"** Bomb attempt failed, the bomb fragments seriously injured you!");
new Float: x;
new Float: y;
new Float: z;
SetPlayerPos(playerid,x,y,z+2);
SetPlayerHealth(playerid, 0);
new pname[24];
GetPlayerName(playerid, pname, 24);
new BombMsg[170];
format(BombMsg, sizeof(BombMsg), "2,4** %s (%d) got seriously injured by bomb fragments while trying to place a bomb in a car.", pname,playerid);
IRC_GroupSay(gGroupID, IRC_CHANNEL, BombMsg);
SetPlayerScore(playerid, GetPlayerScore(playerid) -1);
pInfo[playerid][Deaths] ++;
SendDeathMessage(INVALID_PLAYER_ID, playerid, 51);
new all[170];
format(all, sizeof(all), "** %s (%d) got seriously injured by bomb fragments while trying to place a bomb in a car.", pname,playerid);
SCMTA(COLOR_CON_GREEN,all);
}
else
{
new carid;
carid = GetPlayerVehicleID(playerid);
VehicleBombID[playerid] = carid;
SetPVarInt(playerid,"PlantBomb",GetTickCount()+300000);
BombTimer[playerid] = SetTimerEx("BombCar",10000,false,"d",playerid);
pInfo[playerid][BombsPlanted] ++;
pInfo[playerid][Bombs] --;
new BomberMsg[128];
format(BomberMsg, sizeof(BomberMsg), "** Bomb planted, the vehicle will explode in 10 seconds, exit fast! Bombs left: %d", pInfo[playerid][Bombs]);
SCM(playerid,COLOR_CON_GREEN,BomberMsg);
new pname[24];
GetPlayerName(playerid, pname, 24);
new BombedMsg[170];
format(BombedMsg, sizeof(BombedMsg), "2,4** %s (%d) planted a bomb in their car.", pname,playerid);
IRC_GroupSay(gGroupID, IRC_CHANNEL, BombedMsg);
new alll[128];
format(alll, sizeof(alll), "** %s (%d) planted a bomb in their car.", pname,playerid);
SCMTA(COLOR_CON_GREEN,alll);
}
}
return 1;
}
And works, thid is the BombCar timer:

pawn Код:
public BombCar(playerid)
{
    new carid = GetPlayerVehicleID(playerid);
    new Float:vehx, Float:vehy, Float:vehz;
    GetVehiclePos(carid, vehx, vehy, vehz);
    CreateExplosion(VehicleBombID,vehx,vehy,vehz,7,5);
    CreateExplosion(VehicleBombID,vehx,vehy,vehz,5,5);
    CreateExplosion(VehicleBombID,vehx,vehy,vehz,6,5);
    CreateExplosion(VehicleBombID,vehx,vehy,vehz,4,5);
    SetVehicleHealth(VehicleBombID, 0.0);
    new rando = random(12345)+127;
    new exploded[170];
    format(exploded, sizeof(exploded), "** The bomb in the car has exploded and you earned %d CSCash and 1 score!", rando);
    SCM(playerid, COLOR_CON_GREEN, exploded);
    GivePlayerCash(playerid, rando);
    SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
    KillTimer(BombTimer[playerid]);
    return 1;
}
I've stored the vehicle id where the player types /bomb, but seems not work:

Quote:

(2992) : error 035: argument type mismatch (argument 1)
(2993) : error 035: argument type mismatch (argument 1)
(2994) : error 035: argument type mismatch (argument 1)
(2995) : error 035: argument type mismatch (argument 1)
(2996) : error 035: argument type mismatch (argument 1)

Error lines:

pawn Код:
CreateExplosion(VehicleBombID,vehx,vehy,vehz,7,5);
    CreateExplosion(VehicleBombID,vehx,vehy,vehz,5,5);
    CreateExplosion(VehicleBombID,vehx,vehy,vehz,6,5);
    CreateExplosion(VehicleBombID,vehx,vehy,vehz,4,5);
    SetVehicleHealth(VehicleBombID, 0.0);
To store the vehicle id, in /bomb cmd i used:

pawn Код:
VehicleBombID[playerid] = carid;
Whats wrong? I need to store the vehicleid of where the player types bomb, than if he exit, the explosions will destroy ONLY that vehicleid where the bomb has been placed.
Reply
#2

pawn Код:
CreateExplosion(VehicleBombID,
VehicleBombID is player array, not variable like you used it in CreateExplosion function.
pawn Код:
VehicleBombID[playerid] // Array
VehicleBombID // Variable
Quote:

everything works except a thing, the bomb explosion.

LMAO.
Reply
#3

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
pawn Код:
CreateExplosion(VehicleBombID,
VehicleBombID is player array, not variable like you used it in CreateExplosion function.
pawn Код:
VehicleBombID[playerid] // Array
VehicleBombID // Variable

LMAO.
Emh whats so funny? lol. Btw i edited in this way:

pawn Код:
CreateExplosion(VehicleBombID[playerid],vehx,vehy,vehz,7,5);
    CreateExplosion(VehicleBombID[playerid],vehx,vehy,vehz,5,5);
    CreateExplosion(VehicleBombID[playerid],vehx,vehy,vehz,6,5);
    CreateExplosion(VehicleBombID[playerid],vehx,vehy,vehz,4,5);
    SetVehicleHealth(VehicleBombID, 0.0);
Same problem.

I have
pawn Код:
new VehicleBombID[MAX_PLAYERS];
as variable.
Reply
#4

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
Btw i edited in this way:

pawn Код:
CreateExplosion(VehicleBombID[playerid],vehx,vehy,vehz,7,5);
CreateExplosion(VehicleBombID[playerid],vehx,vehy,vehz,5,5);
CreateExplosion(VehicleBombID[playerid],vehx,vehy,vehz,6,5);
CreateExplosion(VehicleBombID[playerid],vehx,vehy,vehz,4,5);
SetVehicleHealth(VehicleBombID, 0.0);
It's not variable it's an player array, and again see this line:

pawn Код:
SetVehicleHealth(VehicleBombID, 0.0);
You forget to use array here, you have to change it to:

pawn Код:
SetVehicleHealth(VehicleBombID[playerid], 0.0);
Quote:
Originally Posted by Logitech90
Emh whats so funny? lol.
And the funny thing is, that you're doing "Bombing vehicles" and everything works except Bomb.
Reply
#5

Still getting warnings on those:

pawn Код:
CreateExplosion(VehicleBombID[playerid],vehx,vehy,vehz,7,5);
    CreateExplosion(VehicleBombID[playerid],vehx,vehy,vehz,5,5);
    CreateExplosion(VehicleBombID[playerid],vehx,vehy,vehz,6,5);
    CreateExplosion(VehicleBombID[playerid],vehx,vehy,vehz,4,5);
number of arguments does not match definition
tagmismatch
Reply
#6

This one:
pawn Код:
new carid = GetPlayerVehicleID(playerid);
Replace with:
pawn Код:
new carid = VehicleBombID[playerid];
And those lines:
pawn Код:
CreateExplosion(VehicleBombID,vehx,vehy,vehz,7,5);
    CreateExplosion(VehicleBombID,vehx,vehy,vehz,5,5);
    CreateExplosion(VehicleBombID,vehx,vehy,vehz,6,5);
    CreateExplosion(VehicleBombID,vehx,vehy,vehz,4,5);
Replace with:
pawn Код:
CreateExplosion(vehx,vehy,vehz,7,5);
    CreateExplosion(vehx,vehy,vehz,5,5);
    CreateExplosion(vehx,vehy,vehz,6,5);
    CreateExplosion(vehx,vehy,vehz,4,5);
https://sampwiki.blast.hk/wiki/CreateExplosion
Reply
#7

Oh its too late.
Reply
#8

<3 Works!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)