Robbing System Advanced

Started by Finch Real, Jul 19, 2016, 08:39 AM

Previous topic - Next topic

Finch Real

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
My Snipet Showroom

http://pastebin.com/5KKuU5cg

Kewun


Kewun

wut?
onPlayer Class
Robskill = 0;
Cash = 0;

what is this?

KAKAN

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
oh no

Finch Real

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
My Snipet Showroom

http://pastebin.com/5KKuU5cg

KAKAN

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.
oh no

Finch Real

Well I am in love with queries
But i will create in classes when i get back at home :)
My Snipet Showroom

http://pastebin.com/5KKuU5cg

MEGAMIND


KAKAN

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
oh no

Finch Real

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 ;)
My Snipet Showroom

http://pastebin.com/5KKuU5cg

KAKAN

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.
oh no

Finch Real

Yeah That's True I can't script that hard but i still love this way with db
My Snipet Showroom

http://pastebin.com/5KKuU5cg

Xmair

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

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Finch Real

My Snipet Showroom

http://pastebin.com/5KKuU5cg

KAKAN

oh no