Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: Finch Real on Jul 19, 2016, 08:39 AM

Title: Robbing System Advanced
Post by: Finch Real on Jul 19, 2016, 08:39 AM
Hello As i have Released In Past Robbing System but it was Broken Script So here is the advanced way to add it

Credits : [UF]Decent_946

First Add on Commands

function onPlayerCommand( player, cmd, text )
{
if ( cmd == "robskills" )
{
MessagePlayer( "Your robbing skill are: " + GetRobskills(player) + "." ,player );
}
}

 
 
   Now Work On Functions
   
   Add this on ScriptLoad
   

RobbingSystem();
LoadPickups();
pstats <- array(GetMaxPlayers(), null);
   
   now on Functions.nut
   
   
   
function RobbingSystem()
{
QuerySQL( db, "CREATE TABLE IF NOT EXISTS Robskills( Name TEXT),Robskill NUMERIC )" );
}
function GetRobskills( player )
{
   local Robbing =  GetSQLColumnData( QuerySQL( db, "SELECT Robskill FROM Robskills WHERE Name='" + player.Name+"'" ), 0 );
   if ( Robbing ) return Robbing;
   else return 0;
}
function SetRobskills( player, rob )
{
      QuerySQL(db, "UPDATE Robskills SET Robskill='" +  rob.tointeger() + "' WHERE Name='" + player.Name + "'");   
}
   
   
 
   
   Now Lets Move to PickupPickup
   
   

function onPickupPickedUp( player, pickup )
{
if ( pickup.Model == 408 )
  {
Message("[#FF0000]"+ player.Name +" has Robbing the "+ GetDistrictName( player.Pos.x, player.Pos.y ) +"");
SetRobskills(player,GetRobskills(player)+1);
Announce( "~y~ You have Robbed :25000", player )
player.Cash += 25000;
pickup.RespawnTime = 30000;
}
}
   
   Now CreatePickups
   
   
function LoadPickups()
{
CreatePickup(408, Vector( 204.29, -490.98, 11.06 ));
CreatePickup(408, Vector(-854.526, -631.75, 11.3756 ));
CreatePickup(408, Vector(-688.706, -1262.49, 16.3473 ));
CreatePickup(408, Vector(-665.025, -1484.42, 13.8016 ));
CreatePickup(408, Vector(-885.324, -469.998, 13.1111 ));
CreatePickup(408, Vector(-847.002, -71.6495, 11.5405 ));
CreatePickup(408, Vector(-1079.64, -275.416, 12.0882 ));
CreatePickup(408, Vector(-1036.4 81.2033, 11.6515 ));
CreatePickup(408, Vector(-992.73, 200.392, 15.2213 ));
CreatePickup(408, Vector(-830.158, 741.534, 11.2885 ));
CreatePickup(408, Vector(-906.182, 799.715, 11.4546 ));
CreatePickup(408, Vector(-854.047, 85 11.3846 ));
CreatePickup(408, Vector(-754.53, 1342.74, 11.767 ));
CreatePickup(408, Vector(472.16, 1009.2, 19.1493 ));
CreatePickup(408, Vector(423.496, 1039.0 18.9648 ));
CreatePickup(408, Vector(364.464, 1075.12, 19.0649 ));
CreatePickup(408, Vector(470.443, 1208.18, 19.0094 ));
}
   
   Enjoy ;)
If you find any problem feel free to post here
Title: Re: Robbing System Advanced
Post by: Kewun on Jul 19, 2016, 08:40 AM
nice
Title: Re: Robbing System Advanced
Post by: Kewun on Jul 19, 2016, 08:43 AM
wut?
onPlayer Class
Robskill = 0;
Cash = 0;

what is this?
Title: Re: Robbing System Advanced
Post by: KAKAN on Jul 19, 2016, 08:47 AM
lol, improve it, you do queries all the time, this will lag the shit out of the server if the PC is slow and there are many players :p
Title: Re: Robbing System Advanced
Post by: Finch Real on Jul 19, 2016, 08:50 AM
It don't when you have a good pc :)
I was going to create in hash but i think queries will be better
@Kewun Code Updated
Title: Re: Robbing System Advanced
Post by: KAKAN on Jul 19, 2016, 08:52 AM
Quote from: Finch Real on Jul 19, 2016, 08:50 AMIt don't when you have a good pc :)
I was going to create in hash but i think queries will be better
Why not create a class and store the information in variables, that will be lot more easier to understand as well as efficient.
Even if you have a good PC, it might.
Title: Re: Robbing System Advanced
Post by: Finch Real on Jul 19, 2016, 08:53 AM
Well I am in love with queries
But i will create in classes when i get back at home :)
Title: Re: Robbing System Advanced
Post by: MEGAMIND on Jul 19, 2016, 09:20 AM
......ok cool....
Title: Re: Robbing System Advanced
Post by: KAKAN on Jul 19, 2016, 02:23 PM
So, here's a efficient version of it( untested ), I've left scripting in Squirrel long ago, so, it may contain bugs. It's just an example of how to do that shit efficiently.
Link: http://pastebin.com/qwxYQu8e
Title: Re: Robbing System Advanced
Post by: Finch Real on Jul 19, 2016, 02:28 PM
Well Its Good Example But i think that could be difficult for newbies to handle it so this one is. Most simple example Deal with it ;)
Title: Re: Robbing System Advanced
Post by: KAKAN on Jul 19, 2016, 02:32 PM
Quote from: Finch Real on Jul 19, 2016, 02:28 PMWell Its Good Example But i think that could be difficult for newbies to handle it so this one is. Most simple example Deal with it ;)
You're too stubborn... Well, what do you think? If the newbies don't learn, then they can never script, for example: you.
I've explained that example with comments and other things so it's easy to edit and see for any ONE!
You've neither commented anything nor did you give some space which would make it easier to read and understand.
Title: Re: Robbing System Advanced
Post by: Finch Real on Jul 19, 2016, 02:33 PM
Yeah That's True I can't script that hard but i still love this way with db
Title: Re: Robbing System Advanced
Post by: Xmair on Jul 20, 2016, 05:46 AM
Quote from: Finch Real on Jul 19, 2016, 08:39 AMfunction SetRobskills( player, rob )
{
      QuerySQL(db, "UPDATE Robskills SET Robskills='" +  rob.tointeger() + "' WHERE Name='" + player.Name + "'");   
}
wtf
Title: Re: Robbing System Advanced
Post by: Finch Real on Jul 20, 2016, 06:04 AM
Updated!
Title: Re: Robbing System Advanced
Post by: KAKAN on Jul 20, 2016, 09:21 AM
Quote from: Finch Real on Jul 20, 2016, 06:04 AMUpdated!
wtf did you update? I see nothing new lol
Title: Re: Robbing System Advanced
Post by: Finch Real on Jul 20, 2016, 09:35 AM
There was a bug Which will not increase robskill that's what i fix
Title: Re: Robbing System Advanced
Post by: Kewun on Aug 06, 2016, 10:48 AM
And error:

the index db does not exists
line:
QuerySQL( db, "CREATE TABLE IF NOT EXISTS Robskills( Name TEXT),Robskill NUMERIC )" );

in the RobbingSystem() function
Title: Re: Robbing System Advanced
Post by: EK.IceFlake on Aug 06, 2016, 11:01 AM
:/
db <- ConnectSQL(".sql");
Title: Re: Robbing System Advanced
Post by: Kewun on Aug 06, 2016, 12:11 PM
where put this? onscirpt load?
Title: Re: Robbing System Advanced
Post by: EK.IceFlake on Aug 06, 2016, 12:59 PM
yah
Title: Re: Robbing System Advanced
Post by: Finch Real on Aug 06, 2016, 01:05 PM
Sorry For Inactivity @Kewun Don't you use database system? If no so add this
db <- ConnectSQL( "rob.sql" );
Title: Re: Robbing System Advanced
Post by: Kewun on Aug 06, 2016, 05:19 PM
already fixed
Title: Re: Robbing System Advanced
Post by: W3aPoN^ on Dec 06, 2016, 10:02 AM
Thanks Thanks Thanks Thanks Thanks
WORKING 1000000000% Thanks
Title: Re: Robbing System Advanced
Post by: ! on Dec 08, 2016, 10:05 AM
Admins i think there is no need for adding like button on any board. :-\ :-\
QuoteI think one more rule needs to be added if any one bump for shity comment his warn lvl will be increased.
Title: Re: Robbing System Advanced
Post by: KAKAN on Dec 08, 2016, 12:21 PM
Quote from: zeus on Dec 08, 2016, 10:05 AMAdmins i think there is no need for adding like button on any board. :-\ :-\
QuoteI think one more rule needs to be added if any one bump for shity comment his warn lvl will be increased.
No, bump is required too. And, you can bump any topic on the off-topic section if its worth it.
Title: Re: Robbing System Advanced
Post by: ! on Dec 09, 2016, 04:53 AM
Quote from: KAKAN on Dec 08, 2016, 12:21 PM
Quote from: zeus on Dec 08, 2016, 10:05 AMAdmins i think there is no need for adding like button on any board. :-\ :-\
QuoteI think one more rule needs to be added if any one bump for shity comment his warn lvl will be increased.
No, bump is required too. And, you can bump any topic on the off-topic section if its worth it.
And this is not off-topic section.
Title: Re: Robbing System Advanced
Post by: Radon on Dec 11, 2016, 08:46 PM
Cough, people, for God Sake! Stop bumping old topics just to get useless notifications...