PDA

View Full Version : commands Not working properly


Jokers98s
14/01/2018, 06:19 AM
CMD:carplantbomb(playerid, params[])
{
if(AntiSK[playerid]) return SendClientMessage(playerid, COLOR_RED, "ERROR: "COL_GREY"You're spawn protected.");
if(CBomb[playerid] == 1)
{
new Float: X, Float: Y, Float: Z;
new vehicleid = GetPlayerVehicleID(playerid);
GetVehiclePos(vehicleid, X, Y, Z);
SendClientMessage(playerid, 0xFFFFFFFF, "You planted bomb! Get out of there!");
CArmed[playerid] = 1;
CBomb[playerid] = 0;
}
return 1;
}

CMD:plantbomb(playerid, params[])
{
if(AntiSK[playerid]) return SendClientMessage(playerid, COLOR_RED, "ERROR: "COL_GREY"You're spawn protected.");

if(TB[playerid] == 1)//TB
{
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.1, 0, 0, 0, 0, 1000, 1);
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
BombO = CreateObject(1252, X, Y, Z, 0.0, 0.0, 96.0);
TArmed[playerid] = 1;
TB[playerid] = 0;
}
else return SendClientMessage(playerid, COLOR_RED, "ERROR: "COL_GREY"Dont have any Bomb in-hand buy from shop.");
return 1;
}


onplayerkeystates codes below


new pState = GetPlayerState(playerid);
if (pState == PLAYER_STATE_DRIVER)
{
if (newkeys & KEY_UP)
{
if(CArmed[playerid] == 1)
{
if (IsPlayerInAnyVehicle(playerid))
{
new Float:X, Float:Y, Float:Z;
new kills;
new str[150], string[150];
new Name[MAX_PLAYER_NAME]; GetPlayerName(playerid, Name, sizeof(Name));
new vehicleid = GetPlayerVehicleID(playerid);
GetVehiclePos(vehicleid, X, Y, Z);
CreateExplosion(X, Y, Z, 12, 15.0);
CreateExplosion(X, Y, Z, 10, 15.0);
foreach(new i : Player)
{
if(IsPlayerInRangeOfPoint(i, 5.0, X, Y, Z) && pTeam{i} != pTeam{playerid})
{
SetPlayerHealth(i, 0.0);
kills += 1;
}
}
CArmed[playerid] = 0;
GivePlayerScore(playerid, kills);
pInfo[playerid][Kills] += kills;
format(str, sizeof str, "*Your Bomb Exploded and killed %i enemies.", kills);
SendClientMessage(playerid, COLOR_GREEN, str);
format(string, sizeof string, "%s's Bomb Exploded and killed %i enemies.", Name, kills);
SendClientMessageToAll(COLOR_GREEN, string);
}
}
}
}
if (newkeys & KEY_FIRE) //Trigger Bomb
{
if(TArmed[playerid] == 1)
{
new Float:X, Float:Y, Float:Z;
new kills;
new str[150], string[150];
new Name[MAX_PLAYER_NAME]; GetPlayerName(playerid, Name, sizeof(Name));
GetObjectPos(BombO, X, Y, Z);
CreateExplosion(X, Y, Z, 2, 100.0);
CreateExplosion(X, Y, Z, 12, 25.0);
CreateExplosion(X, Y, Z, 10, 30.0);
foreach(new i : Player)
{
if(IsPlayerInRangeOfPoint(i, 5.0, X, Y, Z) && pTeam{i} != pTeam{playerid})
{
SetPlayerHealth(i, 0.0);
kills += 1;
}
}
DestroyObject(BombO);
TArmed[playerid] = 0;
GivePlayerScore(playerid, kills);
pInfo[playerid][Kills] += kills;
format(str, sizeof(str), "*Your Bomb Exploded and killed %i enemies.", kills);
SendClientMessage(playerid, COLOR_GREEN, str);
format(string, sizeof(string), "%s 's Bomb Exploded and killed %i enemies.", Name, kills);
SendClientMessageToAll(COLOR_GREEN, string);
}
}


1.when enter plantbomb no object created
2.when fire button pressed message will be showed but no explosion
3.When W is pressed no car explosion happens
4.When press W no message shown

help me plz

Sew_Sumi
14/01/2018, 08:11 AM
Are you using zcmd? If you are then you don't need the params if you aren't going to use them

Second, where you have this section of code under OnPlayerKeyStateChange

new pState = GetPlayerState(playerid);
if (pState == PLAYER_STATE_DRIVER)
{
if (newkeys & KEY_UP)
{
if(CArmed[playerid] == 1)
{

Every keypress, whatever it is, it's making a variable, and checking if you are the driver.

Check the key first, then check if they are driving.


I'm just going to say you should start from scratch again, and take your time doing this. Logical flow is an important thing to look at.

new vehicleid = GetPlayerVehicleID(playerid);
GetVehiclePos(vehicleid, X, Y, Z);

I'm sure this can be

GetVehiclePos(GetPlayerVehicleID(playerid), X, Y, Z);

for instance.

Jokers98s
14/01/2018, 08:13 AM
ok. Let me try

Jokers98s
14/01/2018, 08:19 AM
the fire button key press is correct right ??
no object created BombO = CreateObject(1252, X, Y, Z, 0.0, 0.0, 96.0);

Sew_Sumi
14/01/2018, 08:25 AM
Fire press should be good.

Try using a command and make the z +4 or something, it may be putting it under the ground.

CMD:testbomb(playerid)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
BombO = CreateObject(1252, X, Y, Z+4, 0.0, 0.0, 96.0);
return 1;
}

I think your Bomb0 needs to be an array somehow to function more in the future. Currently it'll spawn a bomb, (If it works) and the next person to spawn a bomb, will lose that placed bombs ID. So that bomb will stay even when the bomb detonates, and will take the object of the second placed one instead.

Jokers98s
14/01/2018, 08:47 AM
carplant works with an delay.. no problem.. but.. no explosion for plant bomb. when key pressed

Sew_Sumi
14/01/2018, 08:51 AM
pTeam{playerid} Not good...

As I say, rewrite it, and make it more logical, and more 'direct'.


You may want to review the keys, as in one section you are testing the Driver, and the other you aren't.

Jokers98s
14/01/2018, 09:04 AM
car explosion working fyn. i dont think bomb0 coordinate values are not got


GetObjectPos(BombO, X, Y, Z);
CreateExplosion(X, Y, Z, 2, 100.0);

Sew_Sumi
14/01/2018, 09:10 AM
Post up your current code.


Also where are you creating Bomb0... As I said before, it'd be better as an array, as if another player plants a bomb, that bomb will no longer be the one the script is looking at.

Jokers98s
14/01/2018, 09:17 AM
CMD:plantbomb(playerid, params[])
{
if(TB[playerid] == 1)//TB
{
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.1, 0, 0, 0, 0, 1000, 1);
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
BombO = CreateObject(1252, X, Y, Z, 88.0000, 91.0000, -84.0000);
TArmed[playerid] = 1;
TB[playerid] = 0;
}
else return SendClientMessage(playerid, COLOR_RED, "ERROR: "COL_GREY"Dont have any Bomb in-hand buy from shop.");
return 1;
}

onplayerkeystate

if (newkeys & KEY_FIRE)
{
if(TArmed[playerid] == 1)
{
new Float:X, Float:Y, Float:Z;
new kills;
new str[150], string[150];
new Name[MAX_PLAYER_NAME]; GetPlayerName(playerid, Name, sizeof(Name));
GetObjectPos(BombO, X, Y, Z);
CreateExplosion(X, Y, Z, 7, 100.0);
foreach(new i : Player)
{
if(IsPlayerInRangeOfPoint(i, 5.0, X, Y, Z) && pTeam{i} != pTeam{playerid})
{
SetPlayerHealth(i, 0.0);
kills += 1;
}
}
DestroyObject(BombO);
TArmed[playerid] = 0;
GivePlayerScore(playerid, kills);
pInfo[playerid][Kills] += kills;
format(str, sizeof(str), "*Your Bomb Exploded and killed %i enemies.", kills);
SendClientMessage(playerid, COLOR_GREEN, str);
format(string, sizeof(string), "%s 's Bomb Exploded and killed %i enemies.", Name, kills);
SendClientMessageToAll(COLOR_GREEN, string);
}
}

Sew_Sumi
14/01/2018, 09:20 AM
Did you try testbomb? Did you see the bomb...

Where are you creating Bomb0, e.g. new Bomb0;

Jokers98s
14/01/2018, 09:57 AM
noting created nothing saw..