Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Finch on Mar 13, 2015, 03:45 PM

Title: Bomb System
Post by: Finch on Mar 13, 2015, 03:45 PM
Well i am facing problem like i face in offerdrugs i add buybomb and plantbomb command but in playerstats there is gettedbomb = 0;

when i buybomb and type /plantbomb t say in console gettedbomb does not exist
Problem?
Title: Re: Bomb System
Post by: MatheuS on Mar 13, 2015, 05:10 PM
gettedbomb -> 0;
Title: Re: Bomb System
Post by: Sk on Mar 13, 2015, 06:07 PM
Quote from: MatheuS on Mar 13, 2015, 05:10 PMgettedbomb -> 0;
WTH
its like this
gettedbomb<-0;and if playerstats is a class then you have to use it something like this.
SomeArrayOnTop[player.ID].gettedbomb = 1;and that SomeArrayOnTop will be something like this on event onScriptLoad().
SomeArrayOnTop<-array(GetMaxPlayers(),null);
Title: Re: Bomb System
Post by: Thijn on Mar 13, 2015, 06:46 PM
Post your code...
Title: Re: Bomb System
Post by: MacTavish on Mar 13, 2015, 07:27 PM
Very easy just make some changes in Offerdrugs and then that will work for you
Title: Re: Bomb System
Post by: MatheuS on Mar 13, 2015, 08:08 PM
To player
gettedbomb <-array(GetMaxPlayers(),0);
To server

gettedbomb -> 0;
Title: Re: Bomb System
Post by: Finch on Mar 14, 2015, 04:12 AM
else if ( cmd == "plantbomb" )
{
if ( status[player.ID].IsReg == false ) ePrivMessage( "[Error] - You Didnt Registered!", player );
else if ( status[player.ID].IsLogged == false ) ePrivMessage( "[Error] - You didnt Loggin!", player );
if  ( [player.ID].gettedbomb == 1 )
{
 if ( planted == false)
{
                              ClientMessage("You Have Planted The Bomb And It Will Expord in 15 Seconds",player,255,255,0);
                              X=player.Pos;
                              Z=player.Pos;
                              by=player.Name;
                              planted = true;
                              NewTimer("explode",15000,1,player.ID);
}
}   
}                                                       
Title: Re: Bomb System
Post by: MacTavish on Mar 14, 2015, 06:10 AM
Quote from: Finch on Mar 14, 2015, 04:12 AMelse if ( cmd == "plantbomb" )
{
if ( status[player.ID].IsReg == false ) ePrivMessage( "[Error] - You Didnt Registered!", player );
else if ( status[player.ID].IsLogged == false ) ePrivMessage( "[Error] - You didnt Loggin!", player );
if  ( [player.ID].gettedbomb == 1 )
{
 if ( planted == false)
{
ClientMessage("You Have Planted The Bomb And It Will Expord in 15 Seconds",player,255,255,0);
X=player.Pos;
Z=player.Pos;
by=player.Name;
planted = true;
 NewTimer("explode",15000,1,player.ID);
}
}   
}                                                       

It may be like this never tried

else if ( cmd == "plantbomb" )
{
if ( status[player.ID].IsReg == false ) ePrivMessage( "[Error] - You Didnt Registered!", player );
else if ( status[player.ID].IsLogged == false ) ePrivMessage( "[Error] - You didnt Loggin!", player );
else if  (status[player.ID].gettedbomb == false) ePrivMessage( "[Error] - You Haven't Bought Bomb!", player );
else
{
ClientMessage("You Have Planted The Bomb And It Will Explode in 15 Seconds",player,255,255,0);
local  x=player.Pos.x, y= player.Pos.y, z=player.Pos.z, planter=player.ID;
  NewTimer("explode",15000,1,x, y, z, planter);
Announce(" Run Away Or Die",player,6);
status[player.ID].gettedbomb = false;
}
}   

else if ( cmd == "buybomb" )
{
if ( status[player.ID].IsReg == false ) ePrivMessage( "[Error] - You Didnt Registered!", player );
else if (player.Cash < 300 ) ePrivMessage( "[Error] - Not Enough Cash To Buy Bomb", player );
else if ( status[player.ID].IsLogged == false ) ePrivMessage( "[Error] - You didnt Loggin!", player );
else if (status[player.ID].gettedbomb == true) ePrivMessage( "[Error] - You Already Bought An Bomb!", player );
else
{
ClientMessage("You Have Bought An Bomb Place Anywhere To Explode",player,255,255,0);
status[player.ID].gettedbomb = true;
DecCash(player, 300);
}
}                     

Timer
function explode(x, y, z, planter)
{
CreateExplosion( 0, 6, x, y, z, planter, true );
AnnounceAll(" BooM, The Bome has been exploded",6);
}

Add in class
class PlayerStats
{
gettedbomb = false;
}

TESTED ;)

TRY NOW REMOVE OLD COMMANDS CLASSES AND FUNCTION

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi60.tinypic.com%2F2znxtgo.png&hash=4b46f3a86a97881a9d5665395260055d3eef5371)
Title: Re: Bomb System
Post by: Finch on Mar 14, 2015, 08:27 AM
now it saying planted does not exist
Title: Re: Bomb System
Post by: Kratos_ on Mar 14, 2015, 01:55 PM

Quote from: Finch on Mar 14, 2015, 08:27 AMnow it saying planted does not exist

It says line number too . Post the console screenshot with the specific line causing the error . Make sure that you have added planted on class PlayerStats cuz his code works fine except he isn't setting gettedbomb to 0 after bomb has been exploded .

Title: Re: Bomb System
Post by: MacTavish on Mar 14, 2015, 02:00 PM
Quote from: Kratos_ on Mar 14, 2015, 01:55 PMexcept he isn't setting gettedbomb to 0 after bomb has been exploded .

Thanks for pointing out kratos gettedbomb added :)
Title: Re: Bomb System
Post by: Finch on Mar 15, 2015, 05:57 AM
i also add in playerstats planted = false; but it again saying planted does not exist
Title: Re: Bomb System
Post by: Finch on Mar 15, 2015, 10:49 AM
now what i have to do?
Title: Re: Bomb System
Post by: MacTavish on Mar 15, 2015, 11:25 AM
Quote from: Kratos_ on Mar 14, 2015, 01:55 PMIt says line number too . Post the console screenshot with the specific line causing the error .
Title: Re: Bomb System
Post by: Finch on Mar 15, 2015, 12:17 PM
there is no error it just say in console planted does not exist
Title: Re: Bomb System
Post by: Thijn on Mar 15, 2015, 12:48 PM
That is an error... Post a screenshot along with the line numbers the error refers to.
Title: Re: Bomb System
Post by: Finch on Mar 15, 2015, 12:57 PM
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi62.tinypic.com%2F4sgnxz.png&hash=abc7087e5cba0261d96f3c8027ba90d4dc2920eb)

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi60.tinypic.com%2Ft026qh.png&hash=e45734fbcef57abd11b2a09ad2fb4e58b72ac517)
Title: Re: Bomb System
Post by: MacTavish on Mar 15, 2015, 03:54 PM
I've Updated the system try now it will work ;)  CHECK (http://forum.vc-mp.org/?topic=385.msg2417#msg2417)
Title: Re: Bomb System
Post by: Finch on Mar 16, 2015, 10:47 AM
thnx bro you help again