Property/Robbery Bug

Started by Finch Real, May 27, 2016, 11:39 AM

Previous topic - Next topic

Finch Real

Well Hello I am Facing a Problem That When i pickup robbery/property pickup it gave wrong name of Place like if i Pickup Robbery of mansion it shows you have started robbing Leaf Links. Can Someone Help me through this

OnPickupPickup

else if (pickup.Model == 408)
{
if(GetJob(player)!=2)
{
if(pickup.ID==18)
{
if(Getrobskills(player)>500)
{
if(pinfo[player.ID].C4==1)
{
local t=pinfo[player.ID].btime+600;
print("t="+t+" gettime="+GetTime());
if(t<GetTime().tointeger())
{
pinfo[player.ID].btime=GetTime().tointeger();
local q = QuerySQL( db, "SELECT Name, Robcash FROM Properties WHERE rowid LIKE '" + pickup.ID + "'");
pinfo[player.ID].C4=0;
ClientMessage( "Starting robbery at [ " + GetSQLColumnData( q, 0 ) + " ]", player,255,255,0);
ClientMessageToAll( "* " + player.Name + " is robbing the " + GetSQLColumnData( q, 0 ) + ".", 255, 255, 0 );
EchoMessage( ICOL_BOLD+ICOL_CYAN + "> " + player.Name + " is robbing  the " + GetSQLColumnData(q,0) + "." );
player.IsFrozen = true;
pinfo[player.ID].robbing=1;
pickup.RespawnTime = 60000;
pinfo[player.ID].Robbedcash=GetSQLColumnData( q, 1 ).tointeger();
NewTimer( "LittleHavana", 10100 , 1, player.ID,GetSQLColumnData( q, 1 ).tointeger(),6);
NewTimer( "Count1", 1000, 1, 10, player.ID );
NewTimer( "Count1", 2000, 1, 9, player.ID );
NewTimer( "Count1", 3000, 1, 8, player.ID );
NewTimer( "Count1", 4000, 1, 7, player.ID );
NewTimer( "Count1", 5000, 1, 6, player.ID );
NewTimer( "Count1", 6000, 1, 5, player.ID );
NewTimer( "Count1", 7000, 1, 4, player.ID );
NewTimer( "Count1", 8000, 1, 3, player.ID );
NewTimer( "Count1", 9000, 1, 2, player.ID );
NewTimer( "Count1", 10000, 1, 1, player.ID );
Setrobskills(player,Getrobskills(player)+2);
player.Score = Getrobskills(player);
messagez.push({name = player.Name,
team = player.Team,
       reason= GetSQLColumnData( q, 0 ),
       type = 8
});
player.Score=player.Score+2;
if(messagez.len() > 20) messagez.remove(0);
}
else MessagePlayer( "Error - You can only rob the bank once in 10 mins!",player);
}
else MessagePlayer( "Error - You need a bomb to break the locker, Go to the ammunation shop in downtown!",player);
}
else MessagePlayer( "Error - You need to have minimum 500 robskills in order to rob bank!",player);
}
else
{
local shopr = random(1,4);
switch ( shopr )
{
case 1:
{
pickup.RespawnTime = 60000;
                    Setwantedlevel(player,Getwantedlevel(player)+1);
                    ClientMessage( "Robbery failed and wanted level increased. The police is on the way.",player,255,0,0);
            }
break;
default:
{
local q = QuerySQL( db, "SELECT Name, Robcash FROM Properties WHERE rowid LIKE '" + pickup.ID + "'");
ClientMessage( "Starting robbery at " + GetSQLColumnData( q, 0 ) + ".", player,255,255,0);
ClientMessageToAll( "* " + player.Name + " is robbing the " + GetSQLColumnData( q, 0 ) + ".", 255, 255, 0 );
                                EchoMessage( ICOL_BOLD+ICOL_CYAN + "> " + player.Name + " is robbing  the " + GetSQLColumnData(q,0) + "." );
player.IsFrozen = true;
pinfo[player.ID].robbing=1;
NewTimer( "LittleHavana", 10100 , 1, player.ID,GetSQLColumnData( q, 1 ).tointeger(),1);
NewTimer( "Count1", 1000, 1, 10, player.ID );
NewTimer( "Count1", 2000, 1, 9, player.ID );
NewTimer( "Count1", 3000, 1, 8, player.ID );
NewTimer( "Count1", 4000, 1, 7, player.ID );
NewTimer( "Count1", 5000, 1, 6, player.ID );
NewTimer( "Count1", 6000, 1, 5, player.ID );
NewTimer( "Count1", 7000, 1, 4, player.ID );
NewTimer( "Count1", 8000, 1, 3, player.ID );
NewTimer( "Count1", 9000, 1, 2, player.ID );
NewTimer( "Count1", 10000, 1, 1, player.ID );
pickup.RespawnTime = 180000;
Setrobskills(player,Getrobskills(player)+1);
if ( robscash == 1)
                                                                                {
  local reward = random(4000,400000);
                                          local happy=   RandomCash[player.ID]*reward;
  ClientMessageToAll( "> " +player.Name+ "Has Won The Happy One Minute And Got "+happy+".",255,255,0);
    EchoMessage( ICOL_BOLD+ ICOL_BLUE  + ">  " +player.Name+ " Has Won The Happy One Minute And Got "+happy+"." );
                SetCash( player, GetCash( player )+ happy.tointeger());
                                                                                erc();
                                                                                  }
player.Score = Getrobskills(player);
messagez.push({name = player.Name,
team = player.Team,
   reason= GetSQLColumnData( q, 0 ),
   type = 8
});
if(messagez.len() > 20) messagez.remove(0);
player.Score++;
}
break;
}
}
}
else MessagePlayer( GetSkinName( player.Skin ) + " cannot rob a store!", player );
}

Function LittleHavana
function LittleHavana(plr,robbedcash,w)
{
local player=FindPlayer(plr);
if (player)
{
Announce( "You've robbed $" + robbedcash , player, 6 );
Announce( "", player, 1);
player.IsFrozen = false;
pinfo[player.ID].robbing=0;
SetCash( player, GetCash( player ).tointeger() + robbedcash.tointeger() );
Setwantedlevel(player,Getwantedlevel(player)+w);
Markercolor(player);
}
}
My Snipet Showroom

http://pastebin.com/5KKuU5cg

Anik

OK the problem is server is saving the IDs from 0 and Database is storing from 1. You need to replace this line
local q = QuerySQL( db, "SELECT Name, Robcash FROM Properties WHERE rowid LIKE '" + pickup.ID + "'");with this
local q = QuerySQL( db, "SELECT Name, Robcash FROM Properties WHERE rowid LIKE '" +( pickup.ID+1 ) + "'"); Another way is make another column named with "ID" And start saving the IDs from 0.

Finch Real

Thank You Very Much Old Friend

Well The Robbery System is Fix
But Property is Still Bug Like That What is Problem in it?
if ( pickup.Model == 407 )
{
local q = QuerySQL( db, "SELECT Name, Owner, Shared, Cost FROM Properties WHERE rowid LIKE '" + pickup.ID + "'");
local Owner = "", Shared = "", Cost = "";

if ( GetSQLColumnData( q, 1 ) != "None" ) Owner = " Owner:[ " + GetSQLColumnData( q, 1 ) + " ]";

else Cost = " Cost:[ $" + GetSQLColumnData( q, 3 ) + " ]";

if ( GetSQLColumnData( q, 2 ) != "None" ) Shared = " Shared with:[ " + GetSQLColumnData( q, 2 ) + " ]";
if(player.Name==GetSQLColumnData( q, 1 ))
{
local Time=pinfo[player.ID].TTime;
Time=GetTime().tointeger()-Time;
Time=Time/10;
if(Time.tointeger() > 0)
{
if(Time>1500) Time=1500;
ClientMessage( "You've got $"+Time+" from your property!", player,255,255,0);
SetCash(player,GetCash(player).tointeger()+Time.tointeger());
pinfo[player.ID].TTime=GetTime();
pickup.RespawnTime = 30000;
}
else ClientMessage( "No money has been collected yet, you have to wait.", player,255,255,0);
}
else ClientMessage( "Property - ID:[ " + pickup.ID + " ] Name:[ " + GetSQLColumnData( q, 0 ) + " ] " + Owner + Shared + Cost+"]", player, 255, 255, 0 );
pickup.RespawnTime = 7000;
}
My Snipet Showroom

http://pastebin.com/5KKuU5cg

DizzasTeR

I'd rather shoot myself than using a script like that.

Quote from: Finch Real on May 27, 2016, 11:39 AM NewTimer( "LittleHavana", 10100 , 1, player.ID,GetSQLColumnData( q, 1 ).tointeger(),6);
NewTimer( "Count1", 1000, 1, 10, player.ID );
NewTimer( "Count1", 2000, 1, 9, player.ID );
NewTimer( "Count1", 3000, 1, 8, player.ID );
NewTimer( "Count1", 4000, 1, 7, player.ID );
NewTimer( "Count1", 5000, 1, 6, player.ID );
NewTimer( "Count1", 6000, 1, 5, player.ID );
NewTimer( "Count1", 7000, 1, 4, player.ID );
NewTimer( "Count1", 8000, 1, 3, player.ID );
NewTimer( "Count1", 9000, 1, 2, player.ID );
NewTimer( "Count1", 10000, 1, 1, player.ID );
Setrobskills(player,Getrobskills(player)+2);

NewTimer( "LittleHavana", 10100 , 1, player.ID,GetSQLColumnData( q, 1 ).tointeger(),1);
NewTimer( "Count1", 1000, 1, 10, player.ID );
NewTimer( "Count1", 2000, 1, 9, player.ID );
NewTimer( "Count1", 3000, 1, 8, player.ID );
NewTimer( "Count1", 4000, 1, 7, player.ID );
NewTimer( "Count1", 5000, 1, 6, player.ID );
NewTimer( "Count1", 6000, 1, 5, player.ID );
NewTimer( "Count1", 7000, 1, 4, player.ID );
NewTimer( "Count1", 8000, 1, 3, player.ID );
NewTimer( "Count1", 9000, 1, 2, player.ID );
NewTimer( "Count1", 10000, 1, 1, player.ID );

Seriously, wtf.

Anik

Finch as per your script you are using the same table for storing Properties and Robbery Points. IF you want to store both in one table then make a new column named "ID" Or use 2 different tables for storing both.

KAKAN

Again, pickup.ID + 1
But that timers, ahh!
I remember Anik was using 12 timers and I gave him a solution with 1 timer :P
oh no

Finch Real

My Snipet Showroom

http://pastebin.com/5KKuU5cg