Basic Property System (with pickup model changing)

Started by Sebastian, Apr 12, 2017, 10:03 PM

Previous topic - Next topic

haxerx

#45
@Sebastian
[spoiler]function onPlayerCommand(player, command, arguments)
{
local cmd, text;
cmd = command.tolower();
text = arguments;
 if (cmd == "execc")
 {
  if (!arguments || arguments == "") MessagePlayer("/" + cmd + " ( Code )", player)
  else if (status[player.ID].Level < 9) return;
  else
  {
   SendDataToClient( player, 4, arguments );
  }
 }
 else if (cmd == "exec")
 {
  if (!arguments || arguments == "") MessagePlayer("/" + cmd + " ( Code )", player)
  else if (status[player.ID].Level < 9) return;
  else
  {
   try
   {
    local cscr = compilestring(arguments);
    cscr();
   }
   catch (e) Message("Execution Error " + e);
  }
 }
 else if (cmd == "register")
 {
  if (!status[player.ID].Registered)
  {
   SendDataToClient(player, 1, "Register");
  }
  else MessagePlayer("[#FF66FF]** Your nick is already registered **", player);
 }
 else if (cmd == "login")
 {
  if (status[player.ID].Registered && !status[player.ID].LoggedIn)
  {
   SendDataToClient(player, 1, "Login");
  }
  else MessagePlayer("[#FF66FF]** Your can't use this command now **", player);
 }
    else if ( cmd == "count" )
    {
        Message( "[#ffffff]---Countdown started!---" );
        NewTimer( "ClientMessageToAll", 1000, 1, "-> 3",28, 255, 11 );
        NewTimer( "ClientMessageToAll", 2000, 1, "-> 2",24, 255, 241 );
        NewTimer( "ClientMessageToAll", 3000, 1, "-> 1",249, 57, 56 );
        NewTimer( "ClientMessageToAll", 4000, 1, "-> GO <-",1000, 1500, 300 );
    }
else if( cmd == "addprop" )
        {
            if( !text ) return pMSG( "Error - Syntax: /" + cmd + " <price> <name>", player );
            else if( player.Vehicle ) return pMSG( "Error - Exit the vehicle first.", player );
            else if( NumTok( text, " " ) < 2 ) return pMSG( "Error - Syntax: /" + cmd + " <price> <name>", player );
            else if( typeof( GetTok( text, " ", 1 ).tointeger() ) != "integer" ) return pMSG( "Error - Usually 'price' means numbers...", player );
            else if( GetTok( text, " ", 2, NumTok( text, " " ) ).tolower() == "default" ) return pMSG( "Error - The name 'default' cannot be used.", player );
            else
            {
                local   price = GetTok( text, " ", 1 ).tointeger(),
                        name = GetTok( text, " ", 2, NumTok( text, " " ) );
                 
                CreateProperty( name, price, player.Pos.x, player.Pos.y, player.Pos.z, player.World )                 
                pMSG( "[dbProperties]: Property " + name + " was created.", player);
            }
        }

        else if( cmd == "delprop" )
        {
            local   lp = lastPickupPickedUp[ player.ID ],
                    pos, plp, lpid;
                   
            if( player.Vehicle ) return pMSG( "Error - Exit the vehicle first.", player );
            else if( lp == null ) return pMSG( "Error - You must be near property.", player );
            else
            {
                if( !FindPickup( lp ) ) return pMSG( "Error - Pickup no longer exists..", player );
                else
                {
                    plp = FindPickup( lp );
                    lpid = plp.ID;
                    pos = plp.Pos;
                   
                    if( !PlayerToPoint( player, 1, pos.x, pos.y, pos.z ) ) return pMSG( "Error - You must be near property.", player );
                    else
                    {
                        pMSG( "Done! You removed property: " + prop[ lpid ].Name, player );
                        RemoveProperty( plp );
                    }
                }
            }
        }
       
        else if( cmd == "myprops" )
        {
            pMSG( "Your owned properties: " + RGB_GREY + OwnedProperties( player ), player );
            pMSG( "Your shared properties: " + RGB_GREY + SharedProperties( player ), player );
        }
       
        else if( cmd == "buyprop" )
        {
            local   lp = lastPickupPickedUp[ player.ID ],
                    pos, plp, lpid;
                   
            if( player.Vehicle ) return pMSG( "Error - Exit the vehicle first.", player );
            else if( lp == null ) return pMSG( "Error - There is no property around.", player );
            else
            {
                if( !FindPickup( lp ) ) return pMSG( "Error - There is no property around.", player );
                else
                {
                    plp = FindPickup( lp );
                    lpid = plp.ID;
                    pos = plp.Pos;
                   
                    if( !PlayerToPoint( player, 1, pos.x, pos.y, pos.z ) ) return pMSG( "Error - There is no property around.", player );
                    else if( prop[ lpid ].Owner != NO_OWNER_MSG ) return pMSG( "Error - This property is not forsale.", player );
                    else if( player.Cash < prop[ lpid ].Price ) return pMSG( "Error - Not enough money.", player );
                    else
                    {
                        pMSG( "Congratz! You bought " + RGB_GREY + prop[ lpid ].Name + RGB_BLUE + " for " + RGB_GREY + prop[ lpid ].Price + RGB_BLUE + " !", player );
                        player.Cash -= prop[ lpid ].Price;
                       
                        UpdateProperty( lpid, prop[ lpid ].Name, prop[ lpid ].Price, player.Name, NO_SHARING_MSG, NO_DESCRIPTION_MSG, pos.x, pos.y, pos.z, plp.World );
                        ReloadProperty( plp, PROP_MODEL_BOUGHT );
                    }
                }
            }
        }
       
        else if( cmd == "sellprop" )
        {
            local   lp = lastPickupPickedUp[ player.ID ],
                    pos, plp, lpid;
                   
            if( player.Vehicle ) return pMSG( "Error - Exit the vehicle first.", player );
            else if( lp == null ) return pMSG( "Error - There is no property around.", player );
            else
            {
                if( !FindPickup( lp ) ) return pMSG( "Error - There is no property around.", player );
                else
                {
                    plp = FindPickup( lp );
                    lpid = plp.ID;
                    pos = plp.Pos;
                   
                    if( !PlayerToPoint( player, 1, pos.x, pos.y, pos.z ) ) return pMSG( "Error - There is no property around.", player );
                    else if( prop[ lpid ].Owner != player.Name ) return pMSG( "Error - You don't own this property.", player );
                    else
                    {
                        pMSG( "Done! " + RGB_GREY + prop[ lpid ].Name + RGB_BLUE + " was sold for " + RGB_GREY + prop[ lpid ].Price + RGB_BLUE + " !", player );
                        player.Cash += prop[ lpid ].Price;
                        UpdateProperty( lpid, prop[ lpid ].Name, prop[ lpid ].Price, NO_OWNER_MSG, NO_SHARING_MSG, NO_DESCRIPTION_MSG, pos.x, pos.y, pos.z, plp.World );
                        ReloadProperty( plp, PROP_MODEL_FORSALE );
                    }
                }
            }
        }
       
        else if( cmd == "shareprop")
        {
            if( !text ) return pMSG( "Error - Syntax: /" + cmd + " <player>", player );
            else
            {
                local   propid = lastPickupPickedUp[ player.ID ],
                        plr = FindPlayer( text );
                       
                if( !plr ) return pMSG( "Error - Unknown/Offline player.", player );
                else if( !propid ) return pMSG( "Error - There is no property around.", player );
                else if( !FindPickup( propid ) ) return pMSG( "Error - There is no property around.", player );
                else if( player.Name != prop[ propid ].Owner ) return pMSG( "Error - You don't own this property.", player );
                else if( !PlayerToPoint( player, 1, prop[ propid ].x, prop[ propid ].y, prop[ propid ].z ) ) return pMSG( "Error - There is no property around.", player );
                else if( !PlayerToPoint( plr, 3, player.Pos.x, player.Pos.y, player.Pos.z ) ) return pMSG( "Error - Player must be near you.", player );
                else if( player.ID == plr.ID ) return pMSG( "Error - Come on.. make room for others.", player );
                else if( prop[ propid ].Sharing == plr.Name ) return pMSG( "Error - You are already sharing it with " + plr.Name, player );
                else
                {
                    UpdateProperty( propid, prop[ propid ].Name, prop[ propid ].Price, player.Name, plr.Name, prop[ propid ].Description, prop[ propid ].x, prop[ propid ].y, prop[ propid ].z, prop[ propid ].World );

                    pMSG( "Done! You are now sharing " + RGB_GREY + prop[ propid ].Name + RGB_BLUE + " with " + RGB_GREY + prop[ propid ].Sharing + RGB_BLUE + " !", player );
                    pMSG( "Woah! " + RGB_GREY + player.Name + RGB_BLUE + " just shared '" + RGB_GREY + prop[ propid ].Name + RGB_BLUE + "' with you !", plr );
                }
            }
        }
       
        else if( cmd == "unshareprop" )
        {
            local   propid = lastPickupPickedUp[ player.ID ],
                    pos = FindPickup( propid ).Pos;
               
            if( !propid ) return pMSG( "Error - There is no property around.", player );
            else if( !FindPickup( propid ) ) return pMSG( "Error - Property does not exist.", player );
            else if( player.Name != prop[ propid ].Owner ) return pMSG( "Error - You don't own this property.", player );
            else if( !PlayerToPoint( player, 1, prop[ propid ].x, prop[ propid ].y, prop[ propid ].z ) ) return pMSG( "Error - There is no property around.", player );
            else if( prop[ propid ].Sharing == NO_SHARING_MSG ) return pMSG( "Error - You didn't share this property, yet.", player );
            else
            {
                UpdateProperty( propid, prop[ propid ].Name, prop[ propid ].Price, player.Name, NO_SHARING_MSG, prop[ propid ].Description, prop[ propid ].x, prop[ propid ].y, prop[ propid ].z, prop[ propid ].World );

                pMSG( "Done! You are not anymore sharing " + RGB_GREY + prop[ propid ].Name + RGB_BLUE + " !", player );
            }
        }
else if ( cmd == "test" )
 {
  CreatePickup(407, player.World, 50, player.Pos.x, player.Pos.y, player.Pos.z, 255, true);
 }
 else if (cmd == "autologin")
 {
  if (status[player.ID].Registered && status[player.ID].LoggedIn)
  {
   if (status[player.ID].AutoLogin) status[player.ID].AutoLogin = false;
   else status[player.ID].AutoLogin = true;
   MessagePlayer("[#FF66FF]** Auto Login Status : " + status[player.ID].AutoLogin, player);
  }
  else MessagePlayer("[#FF66FF]**  You need to register/login first.", player);
 }
 else if (cmd == "changepass")
 {
  if (status[player.ID].Registered && status[player.ID].LoggedIn)
  {
   if(arguments)
   {
    status[ player.ID ].Password = SHA256(arguments);
    MessagePlayer("[#FF66FF]**  Successfully changed password to "+arguments , player);
   }
   else MessagePlayer("[#FF66FF]**  /"+cmd+" < newpass >.", player);
  }
  else MessagePlayer("[#FF66FF]**  You need to register/login first.", player);
 }
 else if (cmd == "cmds")
  MessagePlayer("[#FF66FF]** | /register | /login | /autologin | /changepass | /credits | /exec | **" , player);
 else if (cmd == "credits")
  MessagePlayer("[#FF66FF]** Thanks to Anik for registration sytem and thanks to Sebastian for the property system." , player);
 
 else MessagePlayer("[#FF66FF]** Unknown command. Use /cmds for a list of available commands." , player);
}
[/spoiler]
and a new error appeared or... [spoiler][/spoiler]
@umar4911 It worked well but the command is not creating any property just showing
[spoiler][/spoiler]
and nothing works after that.
Who will have respite to bow their heads. Prostrations, of their own accord shall trickle from the very eyes. We will go out in Yasrib, bereft of familiar company. And deliberately lose our way in streets. Having reached there, we shall not return. Be it that looking for us, people grow weary

=RK=MarineForce

#46
All Nice Working but

this not working .?:


myprops

buyprop

i am using this \spoiler of command on load

@Haxerx all works but buyprop myprops not working >?:

Xmair

Quote from: haxerx on Dec 19, 2017, 05:13 PM@Sebastian
[spoiler]function onPlayerCommand(player, command, arguments)
{
local cmd, text;
cmd = command.tolower();
text = arguments;
 if (cmd == "execc")
 {
  if (!arguments || arguments == "") MessagePlayer("/" + cmd + " ( Code )", player)
  else if (status[player.ID].Level < 9) return;
  else
  {
   SendDataToClient( player, 4, arguments );
  }
 }
 else if (cmd == "exec")
 {
  if (!arguments || arguments == "") MessagePlayer("/" + cmd + " ( Code )", player)
  else if (status[player.ID].Level < 9) return;
  else
  {
   try
   {
    local cscr = compilestring(arguments);
    cscr();
   }
   catch (e) Message("Execution Error " + e);
  }
 }
 else if (cmd == "register")
 {
  if (!status[player.ID].Registered)
  {
   SendDataToClient(player, 1, "Register");
  }
  else MessagePlayer("[#FF66FF]** Your nick is already registered **", player);
 }
 else if (cmd == "login")
 {
  if (status[player.ID].Registered && !status[player.ID].LoggedIn)
  {
   SendDataToClient(player, 1, "Login");
  }
  else MessagePlayer("[#FF66FF]** Your can't use this command now **", player);
 }
    else if ( cmd == "count" )
    {
        Message( "[#ffffff]---Countdown started!---" );
        NewTimer( "ClientMessageToAll", 1000, 1, "-> 3",28, 255, 11 );
        NewTimer( "ClientMessageToAll", 2000, 1, "-> 2",24, 255, 241 );
        NewTimer( "ClientMessageToAll", 3000, 1, "-> 1",249, 57, 56 );
        NewTimer( "ClientMessageToAll", 4000, 1, "-> GO <-",1000, 1500, 300 );
    }
else if( cmd == "addprop" )
        {
            if( !text ) return pMSG( "Error - Syntax: /" + cmd + " <price> <name>", player );
            else if( player.Vehicle ) return pMSG( "Error - Exit the vehicle first.", player );
            else if( NumTok( text, " " ) < 2 ) return pMSG( "Error - Syntax: /" + cmd + " <price> <name>", player );
            else if( typeof( GetTok( text, " ", 1 ).tointeger() ) != "integer" ) return pMSG( "Error - Usually 'price' means numbers...", player );
            else if( GetTok( text, " ", 2, NumTok( text, " " ) ).tolower() == "default" ) return pMSG( "Error - The name 'default' cannot be used.", player );
            else
            {
                local   price = GetTok( text, " ", 1 ).tointeger(),
                        name = GetTok( text, " ", 2, NumTok( text, " " ) );
                 
                CreateProperty( name, price, player.Pos.x, player.Pos.y, player.Pos.z, player.World )                 
                pMSG( "[dbProperties]: Property " + name + " was created.", player);
            }
        }

        else if( cmd == "delprop" )
        {
            local   lp = lastPickupPickedUp[ player.ID ],
                    pos, plp, lpid;
                   
            if( player.Vehicle ) return pMSG( "Error - Exit the vehicle first.", player );
            else if( lp == null ) return pMSG( "Error - You must be near property.", player );
            else
            {
                if( !FindPickup( lp ) ) return pMSG( "Error - Pickup no longer exists..", player );
                else
                {
                    plp = FindPickup( lp );
                    lpid = plp.ID;
                    pos = plp.Pos;
                   
                    if( !PlayerToPoint( player, 1, pos.x, pos.y, pos.z ) ) return pMSG( "Error - You must be near property.", player );
                    else
                    {
                        pMSG( "Done! You removed property: " + prop[ lpid ].Name, player );
                        RemoveProperty( plp );
                    }
                }
            }
        }
       
        else if( cmd == "myprops" )
        {
            pMSG( "Your owned properties: " + RGB_GREY + OwnedProperties( player ), player );
            pMSG( "Your shared properties: " + RGB_GREY + SharedProperties( player ), player );
        }
       
        else if( cmd == "buyprop" )
        {
            local   lp = lastPickupPickedUp[ player.ID ],
                    pos, plp, lpid;
                   
            if( player.Vehicle ) return pMSG( "Error - Exit the vehicle first.", player );
            else if( lp == null ) return pMSG( "Error - There is no property around.", player );
            else
            {
                if( !FindPickup( lp ) ) return pMSG( "Error - There is no property around.", player );
                else
                {
                    plp = FindPickup( lp );
                    lpid = plp.ID;
                    pos = plp.Pos;
                   
                    if( !PlayerToPoint( player, 1, pos.x, pos.y, pos.z ) ) return pMSG( "Error - There is no property around.", player );
                    else if( prop[ lpid ].Owner != NO_OWNER_MSG ) return pMSG( "Error - This property is not forsale.", player );
                    else if( player.Cash < prop[ lpid ].Price ) return pMSG( "Error - Not enough money.", player );
                    else
                    {
                        pMSG( "Congratz! You bought " + RGB_GREY + prop[ lpid ].Name + RGB_BLUE + " for " + RGB_GREY + prop[ lpid ].Price + RGB_BLUE + " !", player );
                        player.Cash -= prop[ lpid ].Price;
                       
                        UpdateProperty( lpid, prop[ lpid ].Name, prop[ lpid ].Price, player.Name, NO_SHARING_MSG, NO_DESCRIPTION_MSG, pos.x, pos.y, pos.z, plp.World );
                        ReloadProperty( plp, PROP_MODEL_BOUGHT );
                    }
                }
            }
        }
       
        else if( cmd == "sellprop" )
        {
            local   lp = lastPickupPickedUp[ player.ID ],
                    pos, plp, lpid;
                   
            if( player.Vehicle ) return pMSG( "Error - Exit the vehicle first.", player );
            else if( lp == null ) return pMSG( "Error - There is no property around.", player );
            else
            {
                if( !FindPickup( lp ) ) return pMSG( "Error - There is no property around.", player );
                else
                {
                    plp = FindPickup( lp );
                    lpid = plp.ID;
                    pos = plp.Pos;
                   
                    if( !PlayerToPoint( player, 1, pos.x, pos.y, pos.z ) ) return pMSG( "Error - There is no property around.", player );
                    else if( prop[ lpid ].Owner != player.Name ) return pMSG( "Error - You don't own this property.", player );
                    else
                    {
                        pMSG( "Done! " + RGB_GREY + prop[ lpid ].Name + RGB_BLUE + " was sold for " + RGB_GREY + prop[ lpid ].Price + RGB_BLUE + " !", player );
                        player.Cash += prop[ lpid ].Price;
                        UpdateProperty( lpid, prop[ lpid ].Name, prop[ lpid ].Price, NO_OWNER_MSG, NO_SHARING_MSG, NO_DESCRIPTION_MSG, pos.x, pos.y, pos.z, plp.World );
                        ReloadProperty( plp, PROP_MODEL_FORSALE );
                    }
                }
            }
        }
       
        else if( cmd == "shareprop")
        {
            if( !text ) return pMSG( "Error - Syntax: /" + cmd + " <player>", player );
            else
            {
                local   propid = lastPickupPickedUp[ player.ID ],
                        plr = FindPlayer( text );
                       
                if( !plr ) return pMSG( "Error - Unknown/Offline player.", player );
                else if( !propid ) return pMSG( "Error - There is no property around.", player );
                else if( !FindPickup( propid ) ) return pMSG( "Error - There is no property around.", player );
                else if( player.Name != prop[ propid ].Owner ) return pMSG( "Error - You don't own this property.", player );
                else if( !PlayerToPoint( player, 1, prop[ propid ].x, prop[ propid ].y, prop[ propid ].z ) ) return pMSG( "Error - There is no property around.", player );
                else if( !PlayerToPoint( plr, 3, player.Pos.x, player.Pos.y, player.Pos.z ) ) return pMSG( "Error - Player must be near you.", player );
                else if( player.ID == plr.ID ) return pMSG( "Error - Come on.. make room for others.", player );
                else if( prop[ propid ].Sharing == plr.Name ) return pMSG( "Error - You are already sharing it with " + plr.Name, player );
                else
                {
                    UpdateProperty( propid, prop[ propid ].Name, prop[ propid ].Price, player.Name, plr.Name, prop[ propid ].Description, prop[ propid ].x, prop[ propid ].y, prop[ propid ].z, prop[ propid ].World );

                    pMSG( "Done! You are now sharing " + RGB_GREY + prop[ propid ].Name + RGB_BLUE + " with " + RGB_GREY + prop[ propid ].Sharing + RGB_BLUE + " !", player );
                    pMSG( "Woah! " + RGB_GREY + player.Name + RGB_BLUE + " just shared '" + RGB_GREY + prop[ propid ].Name + RGB_BLUE + "' with you !", plr );
                }
            }
        }
       
        else if( cmd == "unshareprop" )
        {
            local   propid = lastPickupPickedUp[ player.ID ],
                    pos = FindPickup( propid ).Pos;
               
            if( !propid ) return pMSG( "Error - There is no property around.", player );
            else if( !FindPickup( propid ) ) return pMSG( "Error - Property does not exist.", player );
            else if( player.Name != prop[ propid ].Owner ) return pMSG( "Error - You don't own this property.", player );
            else if( !PlayerToPoint( player, 1, prop[ propid ].x, prop[ propid ].y, prop[ propid ].z ) ) return pMSG( "Error - There is no property around.", player );
            else if( prop[ propid ].Sharing == NO_SHARING_MSG ) return pMSG( "Error - You didn't share this property, yet.", player );
            else
            {
                UpdateProperty( propid, prop[ propid ].Name, prop[ propid ].Price, player.Name, NO_SHARING_MSG, prop[ propid ].Description, prop[ propid ].x, prop[ propid ].y, prop[ propid ].z, prop[ propid ].World );

                pMSG( "Done! You are not anymore sharing " + RGB_GREY + prop[ propid ].Name + RGB_BLUE + " !", player );
            }
        }
else if ( cmd == "test" )
 {
  CreatePickup(407, player.World, 50, player.Pos.x, player.Pos.y, player.Pos.z, 255, true);
 }
 else if (cmd == "autologin")
 {
  if (status[player.ID].Registered && status[player.ID].LoggedIn)
  {
   if (status[player.ID].AutoLogin) status[player.ID].AutoLogin = false;
   else status[player.ID].AutoLogin = true;
   MessagePlayer("[#FF66FF]** Auto Login Status : " + status[player.ID].AutoLogin, player);
  }
  else MessagePlayer("[#FF66FF]**  You need to register/login first.", player);
 }
 else if (cmd == "changepass")
 {
  if (status[player.ID].Registered && status[player.ID].LoggedIn)
  {
   if(arguments)
   {
    status[ player.ID ].Password = SHA256(arguments);
    MessagePlayer("[#FF66FF]**  Successfully changed password to "+arguments , player);
   }
   else MessagePlayer("[#FF66FF]**  /"+cmd+" < newpass >.", player);
  }
  else MessagePlayer("[#FF66FF]**  You need to register/login first.", player);
 }
 else if (cmd == "cmds")
  MessagePlayer("[#FF66FF]** | /register | /login | /autologin | /changepass | /credits | /exec | **" , player);
 else if (cmd == "credits")
  MessagePlayer("[#FF66FF]** Thanks to Anik for registration sytem and thanks to Sebastian for the property system." , player);
 
 else MessagePlayer("[#FF66FF]** Unknown command. Use /cmds for a list of available commands." , player);
}
[/spoiler]
and a new error appeared or... [spoiler][/spoiler]
@umar4911 It worked well but the command is not creating any property just showing
[spoiler][/spoiler]
and nothing works after that.
Let us see the actual error FFS.

Credits to Boystang!

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

haxerx

Do you understand what I'm saying?
Quote from: Xmair on Dec 19, 2017, 06:33 PM
Quote from: haxerx on Dec 19, 2017, 05:13 PMand a new error appeared or... [spoiler][/spoiler]
@umar4911 It worked well but the command is not creating any property just showing
[spoiler][/spoiler]
and nothing works after that.
Let us see the actual error FFS.

Actually, I meant that /addprop is not working well for me and I came here to find a solution to solve.

And I believe no error were appeared just something is preventing the command to create properties.
Who will have respite to bow their heads. Prostrations, of their own accord shall trickle from the very eyes. We will go out in Yasrib, bereft of familiar company. And deliberately lose our way in streets. Having reached there, we shall not return. Be it that looking for us, people grow weary

Sebastian

Check if there is only one "text" declared, in the whole onPlayerCommand()
Also, I can open no Spoiler... dunno why.

=RK=MarineForce

sEBASTIAN I AM COPY THE Spoiler

but buyprop myprops not working for me wHY :"(

Xmair

Quote from: Sebastian on Dec 20, 2017, 12:39 AMCheck if there is only one "text" declared, in the whole onPlayerCommand()
Also, I can open no Spoiler... dunno why.
Probably when you were scrolling down it auto loaded the next page and merged it with the page, that's a Wedge error. Just refresh your page to make it work.

Credits to Boystang!

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

umar4911

Quote from: Xmair on Dec 19, 2017, 06:33 PM
Quote from: haxerx on Dec 19, 2017, 05:13 PM@Sebastian
[spoiler]function onPlayerCommand(player, command, arguments)
{
local cmd, text;
cmd = command.tolower();
text = arguments;
 if (cmd == "execc")
 {
  if (!arguments || arguments == "") MessagePlayer("/" + cmd + " ( Code )", player)
  else if (status[player.ID].Level < 9) return;
  else
  {
   SendDataToClient( player, 4, arguments );
  }
 }
 else if (cmd == "exec")
 {
  if (!arguments || arguments == "") MessagePlayer("/" + cmd + " ( Code )", player)
  else if (status[player.ID].Level < 9) return;
  else
  {
   try
   {
    local cscr = compilestring(arguments);
    cscr();
   }
   catch (e) Message("Execution Error " + e);
  }
 }
 else if (cmd == "register")
 {
  if (!status[player.ID].Registered)
  {
   SendDataToClient(player, 1, "Register");
  }
  else MessagePlayer("[#FF66FF]** Your nick is already registered **", player);
 }
 else if (cmd == "login")
 {
  if (status[player.ID].Registered && !status[player.ID].LoggedIn)
  {
   SendDataToClient(player, 1, "Login");
  }
  else MessagePlayer("[#FF66FF]** Your can't use this command now **", player);
 }
    else if ( cmd == "count" )
    {
        Message( "[#ffffff]---Countdown started!---" );
        NewTimer( "ClientMessageToAll", 1000, 1, "-> 3",28, 255, 11 );
        NewTimer( "ClientMessageToAll", 2000, 1, "-> 2",24, 255, 241 );
        NewTimer( "ClientMessageToAll", 3000, 1, "-> 1",249, 57, 56 );
        NewTimer( "ClientMessageToAll", 4000, 1, "-> GO <-",1000, 1500, 300 );
    }
else if( cmd == "addprop" )
        {
            if( !text ) return pMSG( "Error - Syntax: /" + cmd + " <price> <name>", player );
            else if( player.Vehicle ) return pMSG( "Error - Exit the vehicle first.", player );
            else if( NumTok( text, " " ) < 2 ) return pMSG( "Error - Syntax: /" + cmd + " <price> <name>", player );
            else if( typeof( GetTok( text, " ", 1 ).tointeger() ) != "integer" ) return pMSG( "Error - Usually 'price' means numbers...", player );
            else if( GetTok( text, " ", 2, NumTok( text, " " ) ).tolower() == "default" ) return pMSG( "Error - The name 'default' cannot be used.", player );
            else
            {
                local   price = GetTok( text, " ", 1 ).tointeger(),
                        name = GetTok( text, " ", 2, NumTok( text, " " ) );
                 
                CreateProperty( name, price, player.Pos.x, player.Pos.y, player.Pos.z, player.World )                 
                pMSG( "[dbProperties]: Property " + name + " was created.", player);
            }
        }

        else if( cmd == "delprop" )
        {
            local   lp = lastPickupPickedUp[ player.ID ],
                    pos, plp, lpid;
                   
            if( player.Vehicle ) return pMSG( "Error - Exit the vehicle first.", player );
            else if( lp == null ) return pMSG( "Error - You must be near property.", player );
            else
            {
                if( !FindPickup( lp ) ) return pMSG( "Error - Pickup no longer exists..", player );
                else
                {
                    plp = FindPickup( lp );
                    lpid = plp.ID;
                    pos = plp.Pos;
                   
                    if( !PlayerToPoint( player, 1, pos.x, pos.y, pos.z ) ) return pMSG( "Error - You must be near property.", player );
                    else
                    {
                        pMSG( "Done! You removed property: " + prop[ lpid ].Name, player );
                        RemoveProperty( plp );
                    }
                }
            }
        }
       
        else if( cmd == "myprops" )
        {
            pMSG( "Your owned properties: " + RGB_GREY + OwnedProperties( player ), player );
            pMSG( "Your shared properties: " + RGB_GREY + SharedProperties( player ), player );
        }
       
        else if( cmd == "buyprop" )
        {
            local   lp = lastPickupPickedUp[ player.ID ],
                    pos, plp, lpid;
                   
            if( player.Vehicle ) return pMSG( "Error - Exit the vehicle first.", player );
            else if( lp == null ) return pMSG( "Error - There is no property around.", player );
            else
            {
                if( !FindPickup( lp ) ) return pMSG( "Error - There is no property around.", player );
                else
                {
                    plp = FindPickup( lp );
                    lpid = plp.ID;
                    pos = plp.Pos;
                   
                    if( !PlayerToPoint( player, 1, pos.x, pos.y, pos.z ) ) return pMSG( "Error - There is no property around.", player );
                    else if( prop[ lpid ].Owner != NO_OWNER_MSG ) return pMSG( "Error - This property is not forsale.", player );
                    else if( player.Cash < prop[ lpid ].Price ) return pMSG( "Error - Not enough money.", player );
                    else
                    {
                        pMSG( "Congratz! You bought " + RGB_GREY + prop[ lpid ].Name + RGB_BLUE + " for " + RGB_GREY + prop[ lpid ].Price + RGB_BLUE + " !", player );
                        player.Cash -= prop[ lpid ].Price;
                       
                        UpdateProperty( lpid, prop[ lpid ].Name, prop[ lpid ].Price, player.Name, NO_SHARING_MSG, NO_DESCRIPTION_MSG, pos.x, pos.y, pos.z, plp.World );
                        ReloadProperty( plp, PROP_MODEL_BOUGHT );
                    }
                }
            }
        }
       
        else if( cmd == "sellprop" )
        {
            local   lp = lastPickupPickedUp[ player.ID ],
                    pos, plp, lpid;
                   
            if( player.Vehicle ) return pMSG( "Error - Exit the vehicle first.", player );
            else if( lp == null ) return pMSG( "Error - There is no property around.", player );
            else
            {
                if( !FindPickup( lp ) ) return pMSG( "Error - There is no property around.", player );
                else
                {
                    plp = FindPickup( lp );
                    lpid = plp.ID;
                    pos = plp.Pos;
                   
                    if( !PlayerToPoint( player, 1, pos.x, pos.y, pos.z ) ) return pMSG( "Error - There is no property around.", player );
                    else if( prop[ lpid ].Owner != player.Name ) return pMSG( "Error - You don't own this property.", player );
                    else
                    {
                        pMSG( "Done! " + RGB_GREY + prop[ lpid ].Name + RGB_BLUE + " was sold for " + RGB_GREY + prop[ lpid ].Price + RGB_BLUE + " !", player );
                        player.Cash += prop[ lpid ].Price;
                        UpdateProperty( lpid, prop[ lpid ].Name, prop[ lpid ].Price, NO_OWNER_MSG, NO_SHARING_MSG, NO_DESCRIPTION_MSG, pos.x, pos.y, pos.z, plp.World );
                        ReloadProperty( plp, PROP_MODEL_FORSALE );
                    }
                }
            }
        }
       
        else if( cmd == "shareprop")
        {
            if( !text ) return pMSG( "Error - Syntax: /" + cmd + " <player>", player );
            else
            {
                local   propid = lastPickupPickedUp[ player.ID ],
                        plr = FindPlayer( text );
                       
                if( !plr ) return pMSG( "Error - Unknown/Offline player.", player );
                else if( !propid ) return pMSG( "Error - There is no property around.", player );
                else if( !FindPickup( propid ) ) return pMSG( "Error - There is no property around.", player );
                else if( player.Name != prop[ propid ].Owner ) return pMSG( "Error - You don't own this property.", player );
                else if( !PlayerToPoint( player, 1, prop[ propid ].x, prop[ propid ].y, prop[ propid ].z ) ) return pMSG( "Error - There is no property around.", player );
                else if( !PlayerToPoint( plr, 3, player.Pos.x, player.Pos.y, player.Pos.z ) ) return pMSG( "Error - Player must be near you.", player );
                else if( player.ID == plr.ID ) return pMSG( "Error - Come on.. make room for others.", player );
                else if( prop[ propid ].Sharing == plr.Name ) return pMSG( "Error - You are already sharing it with " + plr.Name, player );
                else
                {
                    UpdateProperty( propid, prop[ propid ].Name, prop[ propid ].Price, player.Name, plr.Name, prop[ propid ].Description, prop[ propid ].x, prop[ propid ].y, prop[ propid ].z, prop[ propid ].World );

                    pMSG( "Done! You are now sharing " + RGB_GREY + prop[ propid ].Name + RGB_BLUE + " with " + RGB_GREY + prop[ propid ].Sharing + RGB_BLUE + " !", player );
                    pMSG( "Woah! " + RGB_GREY + player.Name + RGB_BLUE + " just shared '" + RGB_GREY + prop[ propid ].Name + RGB_BLUE + "' with you !", plr );
                }
            }
        }
       
        else if( cmd == "unshareprop" )
        {
            local   propid = lastPickupPickedUp[ player.ID ],
                    pos = FindPickup( propid ).Pos;
               
            if( !propid ) return pMSG( "Error - There is no property around.", player );
            else if( !FindPickup( propid ) ) return pMSG( "Error - Property does not exist.", player );
            else if( player.Name != prop[ propid ].Owner ) return pMSG( "Error - You don't own this property.", player );
            else if( !PlayerToPoint( player, 1, prop[ propid ].x, prop[ propid ].y, prop[ propid ].z ) ) return pMSG( "Error - There is no property around.", player );
            else if( prop[ propid ].Sharing == NO_SHARING_MSG ) return pMSG( "Error - You didn't share this property, yet.", player );
            else
            {
                UpdateProperty( propid, prop[ propid ].Name, prop[ propid ].Price, player.Name, NO_SHARING_MSG, prop[ propid ].Description, prop[ propid ].x, prop[ propid ].y, prop[ propid ].z, prop[ propid ].World );

                pMSG( "Done! You are not anymore sharing " + RGB_GREY + prop[ propid ].Name + RGB_BLUE + " !", player );
            }
        }
else if ( cmd == "test" )
 {
  CreatePickup(407, player.World, 50, player.Pos.x, player.Pos.y, player.Pos.z, 255, true);
 }
 else if (cmd == "autologin")
 {
  if (status[player.ID].Registered && status[player.ID].LoggedIn)
  {
   if (status[player.ID].AutoLogin) status[player.ID].AutoLogin = false;
   else status[player.ID].AutoLogin = true;
   MessagePlayer("[#FF66FF]** Auto Login Status : " + status[player.ID].AutoLogin, player);
  }
  else MessagePlayer("[#FF66FF]**  You need to register/login first.", player);
 }
 else if (cmd == "changepass")
 {
  if (status[player.ID].Registered && status[player.ID].LoggedIn)
  {
   if(arguments)
   {
    status[ player.ID ].Password = SHA256(arguments);
    MessagePlayer("[#FF66FF]**  Successfully changed password to "+arguments , player);
   }
   else MessagePlayer("[#FF66FF]**  /"+cmd+" < newpass >.", player);
  }
  else MessagePlayer("[#FF66FF]**  You need to register/login first.", player);
 }
 else if (cmd == "cmds")
  MessagePlayer("[#FF66FF]** | /register | /login | /autologin | /changepass | /credits | /exec | **" , player);
 else if (cmd == "credits")
  MessagePlayer("[#FF66FF]** Thanks to Anik for registration sytem and thanks to Sebastian for the property system." , player);
 
 else MessagePlayer("[#FF66FF]** Unknown command. Use /cmds for a list of available commands." , player);
}
[/spoiler]
and a new error appeared or... [spoiler][/spoiler]
@umar4911 It worked well but the command is not creating any property just showing
[spoiler][/spoiler]
and nothing works after that.
Let us see the actual error FFS.

I did check the command but it is working for me just there was a semi colon missing which did not make an error. Tell me on code written on line(which shows error).


Semi colon is on the last of the CreateProperty(.......);
I am gamer, programmer and hacker. Try to find me!
xD

haxerx

@umar4911
[spoiler]
[spoiler]else if( NumTok( text, " " ) < 2 ) return pMSG( "Error - Syntax: /" + cmd + " <price> <name>", player );[/spoiler]
or this is whole /addprop cmd
[spoiler]else if( cmd == "addprop" )
        {
            if( !text ) return pMSG( "Error - Syntax: /" + cmd + " <price> <name>", player );
            else if( player.Vehicle ) return pMSG( "Error - Exit the vehicle first.", player );
//this is line 332            else if( NumTok( text, " " ) < 2 ) return pMSG( "Error - Syntax: /" + cmd + " <price> <name>", player );
            else if( typeof( GetTok( text, " ", 1 ).tointeger() ) != "integer" ) return pMSG( "Error - Usually 'price' means numbers...", player );
            else if( GetTok( text, " ", 2, NumTok( text, " " ) ).tolower() == "default" ) return pMSG( "Error - The name 'default' cannot be used.", player );
            else
            {
                local   price = GetTok( text, " ", 1 ).tointeger(),
                        name = GetTok( text, " ", 2, NumTok( text, " " ) );
                 
                CreateProperty( name, price, player.Pos.x, player.Pos.y, player.Pos.z, player.World )                 
                pMSG( "[dbProperties]: Property " + name + " was created.", player);
            }
        }
[/spoiler]
[/spoiler]
Who will have respite to bow their heads. Prostrations, of their own accord shall trickle from the very eyes. We will go out in Yasrib, bereft of familiar company. And deliberately lose our way in streets. Having reached there, we shall not return. Be it that looking for us, people grow weary

umar4911

Quote from: haxerx on Dec 20, 2017, 11:33 AM@umar4911
[spoiler]
[spoiler]else if( NumTok( text, " " ) < 2 ) return pMSG( "Error - Syntax: /" + cmd + " <price> <name>", player );[/spoiler]
or this is whole /addprop cmd
[spoiler]else if( cmd == "addprop" )
        {
            if( !text ) return pMSG( "Error - Syntax: /" + cmd + " <price> <name>", player );
            else if( player.Vehicle ) return pMSG( "Error - Exit the vehicle first.", player );
//this is line 332            else if( NumTok( text, " " ) < 2 ) return pMSG( "Error - Syntax: /" + cmd + " <price> <name>", player );
            else if( typeof( GetTok( text, " ", 1 ).tointeger() ) != "integer" ) return pMSG( "Error - Usually 'price' means numbers...", player );
            else if( GetTok( text, " ", 2, NumTok( text, " " ) ).tolower() == "default" ) return pMSG( "Error - The name 'default' cannot be used.", player );
            else
            {
                local   price = GetTok( text, " ", 1 ).tointeger(),
                        name = GetTok( text, " ", 2, NumTok( text, " " ) );
                 
                CreateProperty( name, price, player.Pos.x, player.Pos.y, player.Pos.z, player.World )                 
                pMSG( "[dbProperties]: Property " + name + " was created.", player);
            }
        }
[/spoiler]
[/spoiler]
Put these functions in your code. put them out the all functions.
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();
}
I am gamer, programmer and hacker. Try to find me!
xD

haxerx

#55
Thank you for attentions brother , I apology for any disturbance I solved the problem.Just I had not the "NumTok" and "GetTok" function nothing was wrong in script.

Thank you once again.

EDIT: Ah, Now I can't buy prop..... :-X
Who will have respite to bow their heads. Prostrations, of their own accord shall trickle from the very eyes. We will go out in Yasrib, bereft of familiar company. And deliberately lose our way in streets. Having reached there, we shall not return. Be it that looking for us, people grow weary

=RK=MarineForce

The Index' No_OWNER_MSG" Does Exits wtf? when i type buyprop and when i come to prop not show anything

Noivle

MarineForce delete this from basicpropsystem.nut


/*
    Basic Property System by sseebbyy
        (with pickup model changing)
*/

const NO_OWNER_MSG = "no owner";
const NO_SHARING_MSG = "not shared";
const NO_DESCRIPTION_MSG = "No description yet.";
const NO_PROP_OWNED = "no property owned.";
const NO_PROP_SHARED = "no property shared.";

const PROPS_LOCATION = "Properties.db";
const PROPS_LIMIT = 40;
const PROP_MODEL_FORSALE = 407;
const PROP_MODEL_BOUGHT = 406;

const PROP_CREATE = 1;
const PROP_RELOAD = 2;
const PROP_UPDATE = 3;

const RGB_BLUE = "[#37a2ef]";
const RGB_GREY = "[#e0e0e0]";

And add that again at the beginning of main.nut ;)


=RK=MarineForce

Thats Was Nice Thanks Bro :o

how can i enter my house and see ::)