27.11.2009, 04:43
Hello,i wanted to save bombs,but i dont get it,i made
PlayerInfo[playerid][pBomb];
but where i put it?
dont understand,please someone help
thanks
heres the code:
PlayerInfo[playerid][pBomb];
but where i put it?


heres the code:
pawn Код:
if(strcmp("/setbomb", cmd, true) == 0)
{
new bombs = PlayerInfo[playerid][pBomb] -= 0;
tmp = strtok(cmdtext, idx);
if PlayerInfo[playerid][pBomb] == 1; return SendClientMessage(playerid, ORANGE," You don't have a bomb with you.");
if(!strlen(tmp)) return SendClientMessage(playerid, ORANGE,"USAGE: /setbomb [foot/car]");
else if (strcmp("foot", tmp, true) == 0)
{
if (GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return SendClientMessage(playerid, ORANGE, " You're not on foot");
new Float:X,Float:Y,Float:Z,Float:A;
new playername[24];
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid,A);
GetPlayerName(playerid, playername, 24);
explosive++;
Y += (1 * floatcos(-A, degrees));
X += (1 * floatsin(-A, degrees));
ApplyAnimation(playerid, "BOMBER","BOM_Plant_In",4.0,0,0,0,0,0);
ExplosiveObject[explosive] = CreateObject(1654, X, Y, Z-0.9, 0, 90, 0);
Bomber[playerid] = 1;
BombInfo[explosive][bombX] = X;
BombInfo[explosive][bombY] = Y;
BombInfo[explosive][bombZ] = Z;
strmid(BombInfo[explosive][bombPlanter], playername, 0, strlen(playername), 50);
printf("%d",explosive);
SendClientMessage(playerid,ORANGE," You have planted a bomb on the ground. Type /usebomb to detonate it.");
Bombs[playerid]--;
}
else if (strcmp("car", tmp, true) == 0)
{
if (IsPlayerInAnyVehicle(playerid))
{
new vehicleid = GetPlayerVehicleID(playerid);
new playername[24];
GetPlayerName(playerid, playername, 24);
VehicleBombed[vehicleid] = 1;
Bomber[playerid] = 2;
explosive++;
strmid(BombInfo[explosive][bombPlanter], playername, 0, strlen(playername), 50);
SendClientMessage(playerid,ORANGE," You have planted a bomb inside the car. Type /usebomb to detonate it.");
Bombs[playerid]--;
}
else SendClientMessage(playerid, ORANGE, " You're not inside a vehicle");
}
else SendClientMessage(playerid, ORANGE,"USAGE: /setbomb [foot/car]");
return 1;
}
if (strcmp("/usebomb", cmd, true) == 0)
{
if (Bomber[playerid] == 1) // On foot bomb
{
new playa[128];
GetPlayerName(playerid, playa, 24);
new count = 0;
for(new bomb = 1; bomb < MAX_BOMBS; bomb++)
{
if (!strcmp(BombInfo[bomb][bombPlanter], playa, false)) // if he's the planter of this bomb
{
CreateExplosion(BombInfo[bomb][bombX],BombInfo[bomb][bombY],BombInfo[bomb][bombZ], 7, 7);
DestroyObject(ExplosiveObject[bomb]);
if (explosive <= 0) explosive = 1;
explosive--;
Bomber[playerid] = 0;
BombInfo[bomb][bombX] = 0.0;
BombInfo[bomb][bombY] = 0.0;
BombInfo[bomb][bombZ] = 0.0;
strmid(BombInfo[bomb][bombPlanter], "[NONE]", 0, strlen("[NONE]"), 128);
printf("[ON FOOT] B: %d - E: %d - P: %s",bomb, explosive, BombInfo[bomb][bombPlanter]);
count++;
}
}
format(playa, sizeof(playa), "You activated %d bombs", count);
SendClientMessage(playerid, ORANGE, playa);
}
else if (Bomber[playerid] == 2) // car bomb
{
new playa[128];
GetPlayerName(playerid, playa, 24);
new count = 0;
for(new carbomb = 1; carbomb < MAX_VEHICLES; carbomb++)
{
if (VehicleBombed[carbomb] == 1)
{
new bomb = 0;
while(bomb < MAX_BOMBS)
{
bomb++;
if (strcmp(BombInfo[bomb][bombPlanter], playa, true) == 0) // if he's the planter of this bomb
{
new Float:X,Float:Y,Float:Z;
GetVehiclePos(carbomb,X,Y,Z);
SetVehicleHealth(carbomb,-999);
CreateExplosion(X,Y,Z, 7, 7);
Bomber[playerid] = 0;
VehicleBombed[carbomb] = 0;
strmid(BombInfo[bomb][bombPlanter], "[NONE]", 0, strlen("[NONE]"), 128);
if (explosive <= 0) explosive = 1;
explosive--;
printf("[IN VEH] B: %d - E: %d",bomb, explosive);
count++;
}
}
}
}
format(playa, sizeof(playa), "You activated %d car bombs", count);
SendClientMessage(playerid, ORANGE, playa);
}
return 1;
}
if(strcmp(cmd, "/givebomb", true) == 0)
{
if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, " You're not an admin");
tmp = strtok(cmdtext, idx);
new targetid = ReturnUser(tmp, playerid);
new name[MAX_PLAYER_NAME];
GetPlayerName(targetid, name, sizeof(name));
new tname[MAX_PLAYER_NAME];
GetPlayerName(targetid, tname, sizeof(tname));
tmp = strtok(cmdtext, idx);
new amount = strval(tmp);
if (!strlen(tmp)) amount = 1;
PlayerInfo[targetid][pBomb] + 1;
format(tmp, 128, " You gave %d bombs to %s.",amount, tname);
SendClientMessage(playerid, LIGHTBLUE, tmp);
format(tmp, 128, " You have received %d bombs from %s.",amount, name);
SendClientMessage(targetid, LIGHTBLUE, tmp);
return 1;
}
if(strcmp(cmd, "/buybomb", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerToPoint(3.0,playerid,2049.5945,-2022.9886,13.5469))
{
if(PlayerInfo[playerid][pBomb] == 1)
{
SendClientMessage(playerid, COLOR_GREY, "You already have an bomb!");
return 1;
}
if(GetPlayerMoney(playerid) < 100000)
{
SendClientMessage(playerid, COLOR_GREY, "You don't have enough money for a bomb");
return 1;
}
else
{
SendClientMessage(playerid, COLOR_LIGHTBLUE, "You bought a bomb for 100.000$");
new amount = strval(tmp);
if (!strlen(tmp)) amount = 1;
PlayerInfo[playerid][pBomb] + 1;
SafeGivePlayerMoney(playerid, - 100000);
OnPlayerUpdate(playerid);
}
}
}
return 1;
}