Vice City: Multiplayer

Server Development => Scripting and Server Management => Script Showroom => Topic started by: Gito Baloch on July 18th, 2021, 08:51 AM

Title: ( Simple ) Nogoto on/off system.
Post by: Gito Baloch on July 18th, 2021, 08:51 AM
NOGOTO SYSTEM BY GITO

Class

Code: [Select]
Class PlayerStats{
nogoto = false;
}

Database
Code: [Select]
function onScriptLoad() {
nogoto <- ConnectSQL("Nogoto.db");
QuerySQL(nogoto, "create table if not exists nogoto ( Name Text ,nogoto TEXT) ");
}

Database Close
Code: [Select]
function onScriptUnload() {
DisconnectSQL(nogoto);
}

Functions
Code: [Select]
function Nogoto(player)
{
    local q = QuerySQL(nogoto, "SELECT * FROM nogoto WHERE Name = '" + escapeSQLString(player.Name) + "'");
    if (q)
    {
        stats[ player.ID ].nogoto = GetSQLColumnData( q, 1 );
    }
    else QuerySQL( nogoto, "INSERT INTO nogoto ( Name, nogoto ) VALUES ( '" + escapeSQLString(player.Name) + "', ' false ' )" );
}

function Nogotodb(player)
{
    QuerySQL( nogoto, "UPDATE nogoto SET nogoto='"+ stats[ player.ID ].nogoto +"' WHERE Name = '"+player.Name+"'");
}


PlayerJoin
Code: [Select]
function onPlayerJoin(player){
Nogoto(player);
}

PlayerPart
Code: [Select]
function onPlayerPart(player); {
Nogotodb(player);
}

PlayerCommand
Code: [Select]
function onPlayerCommand(player, cmd, text){
else if(cmd == "nogoto")
{
if(!text) MessagePlayer("[#ff0000]Error: [#ffffff]/" + cmd + " <on/off>", player);
else
{
if(text == "on" || text == "1" || text == "set" || text == "true")
{
                local q = QuerySQL(nogoto, "SELECT * FROM nogoto WHERE Name = '" + player.Name + "'");
            if (stats[player.ID].nogoto == true) MessagePlayer("[#ff0000]Error: [#ffffff]Nogoto is already on!",player);
            else if( q && GetSQLColumnData(q, 1) == "true" ) MessagePlayer("[#ff0000]Error: [#ffffff]Nogoto is already on!",player);
else {
stats[player.ID].nogoto = true;
MessagePlayer("[#ffa447]Nogoto has been turned on, Now no one will be able to teleport to you.",player);
QuerySQL( nogoto, "UPDATE nogoto SET nogoto='"+ stats[ player.ID ].nogoto +"' WHERE Name = '"+player.Name+"'");
        }
        }
if(text == "off" || text == "0" || text == "del" || text == "false")
{
            if (stats[player.ID].nogoto == false) MessagePlayer("[#ff0000]Error: [#ffffff]Nogoto is already off!",player);
else {
stats[player.ID].nogoto = false;
MessagePlayer("[#ffa447]Nogoto has been turned off, Everyone will be able to teleport to you.",player);
     QuerySQL( nogoto, "UPDATE nogoto SET nogoto='"+ stats[ player.ID ].nogoto +"' WHERE Name = '"+player.Name+"'");
}
    }
}
return 0;
}
}



Goto Line
Put this on goto command
Code: [Select]
        local q = QuerySQL(nogoto, "SELECT * FROM nogoto WHERE Name = '" + plr.Name + "'");
    if( q && GetSQLColumnData(q, 1) == "true" ) MessagePlayer("[#ff0000]Error: [#ffffff]Target player has his nogoto enabled!",player);
        else if (stats[plr.ID].nogoto == true) MessagePlayer("[#ff0000]Error: [#ffffff]Target player has his nogoto enabled!",player);


Title: Re: ( Simple ) Nogoto on/off system.
Post by: Rafay on August 27th, 2021, 02:17 PM
Cool! ;D
Title: Re: ( Simple ) Nogoto on/off system.
Post by: Athanatos on October 9th, 2021, 04:12 PM
I'm not 100 % sure, but is it correct to write "Class" instead of "class" in squirreil?
Title: Re: ( Simple ) Nogoto on/off system.
Post by: cowboy on October 9th, 2021, 04:39 PM
Quote from Athanatos on October 9th, 2021, 04:12 PM
I'm not 100 % sure, but is it correct to write "Class" instead of "class" in squirreil?
yes, it should be "class"
+ it's squirrel not squirreil
Title: Re: ( Simple ) Nogoto on/off system.
Post by: Halilibow on November 12th, 2021, 11:57 AM
thanks for this code
Title: Re: ( Simple ) Nogoto on/off system.
Post by: Athanatos on December 1st, 2021, 09:26 PM
Quote from cowboy on October 9th, 2021, 04:39 PM
+ it's squirrel not squirreil
Thank you, I always mistype squirrel