Property script

Started by gamingpro, Mar 27, 2023, 12:08 PM

Previous topic - Next topic

gamingpro

Hi Guys i uploaded Property script, i hope for yours download this script maded by me no helper or Developer in this script



Add That line in onScriptLoad Function.
[noae]
props <- ConnectSQL("props.db");
QuerySQL(props, "CREATE TABLE IF NOT EXISTS prop(ID INTEGER, Price INTEGER, Name TEXT, Owner TEXT, Share TEXT, PX FLOAT, PY FLOAT, PZ FLOAT)");
print("Property System Loaded Succesfully By Gamingpro...");
print("Welcome To Property System....");
print("Maded By:[ gamingpro ]");
LoadProps();
[/noae]
Add this line in onPlayerJoin Function
[noae]
if(player.Name == "Vice-Government" || player.Name == "None"){
Message("[#FF0000]Auto-Kicked:[ "+player.Name+" ] Reason:[ Unauthorized Name. ]");
player.Kick();
}
[/noae]
Add that in onPlayerCommand Function
[noae]
if(cmd == "createprop"){
if(player.Name !="gamingpro") MessagePlayer("[#FF0000]Error: [#FFFFFF]You Don't Have Access To Use This Command!",player); // Here You Can To Change This Name To Your Name!
else {
if(!text) MessagePlayer("[#FF0000]Error: [#FFFFFF]Correct Syntax /"+cmd+" <Price> <Prop Name>",player);
else {
local price = GetTok(text, " ",1);
local pname=  GetTok(text, " ",2 NumTok(text, " "));
if(!IsNum(price)) MessagePlayer("[#FF0000]Error: [#FFFFFF]Price Must Be Integer.",player);
else if(!pname) MessagePlayer("[#FF0000]Error: [#FFFFFF]Please Write The Name of This Prop!.",player);
else {
local q = QuerySQL(props, "SELECT * FROM prop WHERE Name='"+escapeSQLString(pname)+"'");
if(q) MessagePlayer("[#FF0000]Error: [#FFFFFF]Name Already Exist",player);
else {
local proID = GetSQLColumnData(QuerySQL(props, "SELECT COUNT( * ) FROM prop"),0)+1;
QuerySQL(props, "INSERT INTO prop(ID, Price, Name, Owner, Share, PX, PY, PZ) VALUES('"+proID+"','"+price+"','"+pname+"','Vice-Government','None','"+player.Pos.x.tofloat()+"', '"+player.Pos.y.tofloat()+"','"+player.Pos.z.tofloat()+"')");
CreatePickup( 407, Vector(player.Pos.x.tofloat(), player.Pos.y.tofloat(), player.Pos.z.tofloat() ));
MessagePlayer("[#00ff00]pm >> Successfully Created Prop Name:[ "+pname+" ], ID:[ "+proID+" ], Saved in Database!",player);
}
}
}
}
}
else if(cmd == "buyprop"){
if(!text) MessagePlayer("[#FF0000]Error: [#FFFFFF]Correct Syntax /"+cmd+" <Prop ID>",player);
else {
if(!IsNum(text)) MessagePlayer("[#FF0000]Error: [#FFFFFF]ID Must Be Integer.",player);
else if(text.tointeger() < 1 || text.tointeger() > GetPickupCount() ) MessagePlayer("[#FF0000]Error: [#FFFFFF]Invalid Prop ID, Total Props ID Are "+GetPickupCount(),player);
else {
local q = QuerySQL(props, "SELECT * FROM prop WHERE ID='"+text+"'");
local owner = GetSQLColumnData(q,3);
local price = GetSQLColumnData(q,1);
if(owner != "Vice-Government") MessagePlayer("[#FF0000]Error: [#FFFFFF]This Property is Already Sold!",player);
else if(price > player.Cash) MessagePlayer("[#FF0000]Error: [#FFFFFF]Not Enought Money!",player);
else {
QuerySQL(props, "UPDATE prop SET Owner='"+player.Name+"' WHERE ID='"+text+"'");
MessagePlayer("[#00ff00]You've Bought This Property ID:[ "+text+" ]",player);
Announce("You Have Bought New Prop",player,3);
player.Cash -= price; // Here Add Your remove Cash Function!
}
}
}
}
else if(cmd == "sellprop"){
if(!text) MessagePlayer("[#FF0000]Error: [#FFFFFF]Correct Syntax /"+cmd+" <Prop ID>",player);
else {
if(!IsNum(text)) MessagePlayer("[#FF0000]Error: [#FFFFFF]ID Must Be Integer.",player);
else if(text.tointeger() < 1 || text.tointeger() > GetPickupCount()) MessagePlayer("[#FF0000]Error: [#FFFFFF]Invalid Property ID, Total Props ID Are " + GetPickupCount(),player);
else {
local q = QuerySQL(props, "SELECT * FROM prop WHERE ID='"+text+"'");
local owner = GetSQLColumnData(q,3);
local price = GetSQLColumnData(q,1);
if(owner != player.Name) MessagePlayer("[#FF0000]Error: [#FFFFFF]You Don't Own This Property!",player);
else {
QuerySQL(props, "UPDATE prop SET Owner='Vice-Government', Share='None' WHERE ID='"+text+"'");
MessagePlayer("[#00ff00]pm >> You've Sold This Property ID: " + text,player);
player.Cash += price; // Here Add Your Remove Cash Function!.
Announce("Prop Sold",player,3);
}
}
}
}
else if(cmd == "myprops"){
local q = QuerySQL(props, "SELECT * FROM prop WHERE Owner='"+player.Name+"'"), i = 1;
if(!q) MessagePlayer("[#FFFFFF]You Don't Own Any Property",player);
else {
while( GetSQLColumnData(q,3) == player.Name ){
local id = GetSQLColumnData(q,0);
local name = GetSQLColumnData(q,2);
MessagePlayer("[#00ff00]ID:[ "+id+" ], Name:[ "+name+" ]",player);
GetSQLNextRow(q); i++;
}
}
}
else if(cmd == "mysharedprop" || cmd == "mysharedprops"){
local q = QuerySQL(props, "SELECT * FROM prop WHERE Share='"+player.Name+"'"), i = 1;
if(!q) MessagePlayer("[#FFFFFF]You Don't Own Any Shared Property",player);
else {
while( GetSQLColumnData(q,4) == player.Name ){
local id = GetSQLColumnData(q,0);
local name = GetSQLColumnData(q,2);
local owner = GetSQLColumnData(q,3);
MessagePlayer("[#00ff00]ID:[ "+id+" ], Name:[ "+Name+" ], Owner:[ "+owner+" ]",player);
GetSQLNextRow(q); i++;
}
}
}
else if(cmd == "propsforsale" || cmd == "propforsale" || cmd == "propertyforsalte"){
local q = QuerySQL(props, "SELECT * FROM prop WHERE Owner='Vice-Government'"), i = 1;
if(!q) MessagePlayer("[#FFFFFF]No Any Property For Sale",player);
else {
while( GetSQLColumnData(q,3) == "Vice-Government"){
local id = GetSQLColumnData(q,0);
local price = GetSQLColumnData(q,1);
local name = GetSQLColumnData(q,2);
MessagePlayer("[#00ff00]ID:[ "+id+" ], Price:[ "+price+" ], Name:[ "+name+" ]",player);
GetSQLNextRow(q); i++;
}
}
}
else if(cmd == "shareprop"){
if(!text) MessagePlayer("[#FF0000]Error: [#FFFFFF]Correct Syntax /"+cmd+" <Player> <Prop ID>",player);
else {
local plr = GetPlayer(GetTok(text, " ",1));
local id = GetTok(text, " ",2);
if(!plr) MessagePlayer("[#FF0000]Error: [#FFFFFF]Unknow Player!",player);
else if(plr.Name==player.Name) MessagePlayer("[#FF0000]Error: [#FFFFFF]You Can't Share This prop With Your Self!",player);
else if(!id) MessagePlayer("[#FF0000]Error: [#FFFFFF]Write Property ID You Want To Share it With Him",player);
else if(!IsNum(id)) MessagePlayer("[#FF0000]Error: [#FFFFFF]ID Must Be Integer.",player);
else if(id.tointeger() < 1 || id.tointeger() > GetPickupCount()) MessagePlayer("[#FF0000]Error: [#FFFFFF]Invalid Property ID, Total Props ID Are " + GetPickupCount(),player);
else {
local q = QuerySQL(props, "SELECT * FROM prop WHERE ID='"+id+"'");
local share = GetSQLColumnData(q,4);
local owner = GetSQLColumnData(q,3);
if(owner != player.Name) MessagePlayer("[#FF0000]Error: [#FFFFFF]You Don't Own This Property",player);
else if(share == plr.Name) MessagePlayer("[#FF0000]Error: [#FFFFFF]You're Already Shared This Property With Him!.",player);
else {
QuerySQL(props, "UPDATE prop SET Share='"+plr.Name+"' WHERE ID='"+id+"'");
MessagePlayer("[#00ff00]pm >> You've Shared This Property ID:[ "+id+" ] With " + plr.Name,player);
MessagePlayer("[#00ff00]"+player.Name+" Has Shared Property ID:[ "+id+" ] With You",plr);
}
}
}
}
else if(cmd == "unshareprop"){
if(!text) MessagePlayer("[#FF0000]Error: [#FFFFFF]Correct Syntax /"+cmd+" <Prop ID>",player);
else {
if(!IsNum(text)) MessagePlayer("[#FF0000]Error: [#FFFFFF]ID Must Be Integer.",player);
else if(text.tointeger() < 1 || text.tointeger() > GetPickupCount()) MessagePlayer("[#FF0000]Error: [#FFFFFF]Invalid Property ID, Total Props ID Are " + GetPickupCount(),player);
else {
local q = QuerySQL(props, "SELECT * FROM prop WHERE ID='"+text+"'");
local owner = GetSQLColumnData(q,3);
local share = GetSQLColumnData(q,4);
if(owner != player.Name) MessagePlayer("[#FF0000]Error: [#FFFFFF]You Don't Own This property!.",player);
else if(share == "None") MessagePlayer("[#FF0000]Error: [#FFFFFF]You Don't Shared This Property With Any Player!.",player);
else {
QuerySQL(props, "UPDATE prop SET Share='None' WHERE ID='"+text+"'");
MessagePlayer("[#00ff00]pm >> You've Successfully Un-shared Property ID:[ "+text+" ]",player);
}
}
}
}
else if(cmd == "gotoprop"){
if(!text) MessagePlayer("[#FF0000]Error: [#FFFFFF]Correct Syntax /"+cmd+" <Prop ID>",player);
else {
if(!IsNum(text)) MessagePlayer("[#FF0000]Error: [#FFFFFF]ID Must Be Integer.",player);
else if(text.tointeger() < 1 || text.tointeger() > GetPickupCount()) MessagePlayer("[#FF0000]Error: [#FFFFFF]Invalid Property ID, Total Props ID Are " + GetPickupCount(),player);
else {
local q = QuerySQL(props, "SELECT * FROM prop WHERE ID='"+text+"'");
local owner = GetSQLColumnData(q,3);
local share = GetSQLColumnData(q,4);
if(owner != player.Name && share == player.Name || share != player.Name && owner == player.Name){
local PX = GetSQLColumnData(q,5);
local PY = GetSQLColumnData(q,6);
local PZ = GetSQLColumnData(q,7);
player.Pos = Vector( PX.tofloat(), PY.tofloat(), PZ.tofloat() );
MessagePlayer("[#00ff00]Teleported To Property ID:[ "+text+" ]",player);
}
else {MessagePlayer("[#FF0000]Error: [#FFFFFF]You Don't Own This Property",player);}
}
}
}
else if(cmd == "cmds" || cmd == "commands"){
MessagePlayer("[#00ff00]pm >> Property System Commands is: buyprop, sellprop, shareprop, unshareprop, myprops, mysharedprops, createprop ( For Admins ), gotoprop, propsforsale",player);
}
[/noae]
Add that line in onPickupPickedUp Function
[noae]
if(pickup.Model == 407){
local id = pickup.ID+1;
local q = QuerySQL(props, "SELECT * FROM prop WHERE ID='"+id+"'");
if(GetSQLColumnData(q,0) != null){
local owner = GetSQLColumnData(q,3),
price = GetSQLColumnData(q,1),
name = GetSQLColumnData(q,2),
share = GetSQLColumnData(q,4);
MessagePlayer("[#00ff00]ID:[ "+id+" ] Owner:[ "+owner+" ] Price:[ "+price+" ] Name:[ "+name+" ] Share:[ "+share+" ]",player);
pickup.RespawnTime = 3000;
}
}
else return;
[/noae]




Functions
[noae]
function LoadProps(){
local q = QuerySQL(props, "SELECT * FROM prop"), i = 0;
while( GetSQLColumnData(q,0) ){
local PX = GetSQLColumnData(q,5),
PY = GetSQLColumnData(q,6),
PZ = GetSQLColumnData(q,7);
CreatePickup( 407, Vector(PX.tofloat(), PY.tofloat(), PZ.tofloat() ));
GetSQLNextRow(q); i++;
}
print("Props Loaded: "+i+"");
}

function GetTok( string, separator, n, ... )
{
 local m = ( vargv.len() > 0 ) ? vargv[ 0 ] : n, tokenized = split( string, separator ), text = "";

 if ( ( n > tokenized.len() ) || ( n < 1 ) ) return null;

 for ( ; n <= m; n++ )
 {
  text += text == "" ? tokenized[ n - 1 ] : separator + tokenized[ n - 1 ];
 }

 return text;
}
function NumTok(string, separator)
{
    local tokenized = split(string, separator);
    return tokenized.len();
}
function GetPlayer( target )
{
 local target1 = target.tostring();

 if ( IsNum( target ) )
 {
  target = target.tointeger();

  if ( FindPlayer( target) ) return FindPlayer( target );
  else return null;
 }
 else if ( FindPlayer( target ) ) return FindPlayer( target );
 else return null;
}
[/noae]

Halilibow

Nice bro i liked it!  ;D
=M4= Cleo And VC:MP Server Scripting

gamingpro


H.a.S.a.N

Gooodd and great bro :)