Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: [VM_U]Spectra.PhantoM^ on Jan 17, 2016, 05:39 PM

Title: Forcing Spawn/Eject.(UPDATED)
Post by: [VM_U]Spectra.PhantoM^ on Jan 17, 2016, 05:39 PM
I was working on my own server. Built these. Now i know what ur gonna think that "Ultimate u nab this is useless" or  "Useless shit cmd".I TRYED people dont be rude down there in comments. Thanx.

function onPlayerCommand(player, command, arguments)
{
local params;
if (arguments != null) params = split(arguments, " ");
else params = split("", " ");

if (command == "forceeject")
{
local lvl = GetLevel( player );
if (params.len() < 1) EMessagePlayer(player, "Invalid parameters, /forceeject playername reason");

else if (GetLevel() < 7) EMessagePlayer(player,  "Command level too high");

else if (!FindPlayer(params[0])) EMessagePlayer(player,  "Unknown player %s", params[0]);

else

{

local plr = FindPlayer(params[0]);

local veh = player.Vehicle;
EMessageAll("Administrator %s has ejected %s.", player.Name, plr.Name, arguments.slice(params[0].len()));

plr.Eject();
}
return 1;
}

else if (command == "forcespawn")
{
local lvl = GetLevel( player );
if (params.len() < 1) EMessagePlayer(player, "Invalid parameters, /forcespawn playername reason");

else if (GetLevel() < 7) EMessagePlayer(player, "Command level too high");

else if (!FindPlayer(params[0])) EMessagePlayer(player, "Unknown player %s", params[0]);

else

{

local plr = FindPlayer(params[0]);

EMessageAll("Administrator %s has forced %s to spawn.", player.Name, plr.Name, arguments.slice(params[0].len()));

plr.Spawn();
}
return 1;

}

Updated.
function GetLevel( player )
{
local lvl =  GetSQLColumnData( QuerySQL( db, "SELECT Level FROM Account WHERE Name='" + player.Name.tolower() + "'" ), 0 );
if ( lvl ) return lvl;
else return 0;
FreeSQLQuery( lvl );
}
Title: Re: Forcing Spawn/Eject.
Post by: KAKAN on Jan 17, 2016, 06:12 PM
I got one error:-
Error: The index 'EMessagePlayer' doesn't exist.
Title: Re: Forcing Spawn/Eject.
Post by: Thijn on Jan 17, 2016, 06:32 PM
And if you copy-paste this into your own script you would notice you have an else if on your first command, instead of an if.
Title: Re: Forcing Spawn/Eject.
Post by: KAKAN on Jan 17, 2016, 06:37 PM
Quote from: Thijn on Jan 17, 2016, 06:32 PMAnd if you copy-paste this into your own script you would notice you have an else if on your first command, instead of an if.
bugged script. In the 1st command, wtf is this?
else if (player.Level() < 7) EMessagePlayer(player,  "Command level too high");
And wtf is this:-
In the 2nd command you don't even check that if the player is spawned or not.
Title: Re: Forcing Spawn/Eject.
Post by: [VM_U]Spectra.PhantoM^ on Jan 17, 2016, 07:39 PM
Quote from: KAKAN on Jan 17, 2016, 06:12 PMI got one error:-
Error: The index 'EMessagePlayer' doesn't exist.
Replace With MessagePlayer then easy peasy.
Quote from: KAKAN on Jan 17, 2016, 06:37 PM
Quote from: Thijn on Jan 17, 2016, 06:32 PMAnd if you copy-paste this into your own script you would notice you have an else if on your first command, instead of an if.
bugged script. In the 1st command, wtf is this?
else if (player.Level() < 7) EMessagePlayer(player,  "Command level too high");
And wtf is this:-
In the 2nd command you don't even check that if the player is spawned or not.
Sorry Thanx for noting out bug. You can replace EMessagePlayer with MessagePlayer Like this
else if (player.Level() < 7) MessagePlayer("Command level too high", player);Fixed anyways player.Level() < 7 means it cant be used by a person lower than lvl 7.
Title: Re: Forcing Spawn/Eject.
Post by: MacTavish on Jan 17, 2016, 07:49 PM
Quote from: {ultimatejugoSorry Thanx for noting out bug. You can replace EMessagePlayer with MessagePlayer Like this
else if (player.Level() < 7) MessagePlayer("Command level too high", player);Fixed anyways player.Level() < 7 means it cant be used by a person lower than lvl 7.
It wont work because afaik Player.Level is not a Squirrel function. you better check it on Blank script before posting in VCMP community because there are many newbies those copy snippets and after getting error because of a broken script or their weak brain they start spamming the forum
Title: Re: Forcing Spawn/Eject.
Post by: [VM_U]Spectra.PhantoM^ on Jan 17, 2016, 08:07 PM
Quote from: Kusanagi on Jan 17, 2016, 07:49 PM
Quote from: {ultimatejugoSorry Thanx for noting out bug. You can replace EMessagePlayer with MessagePlayer Like this
else if (player.Level() < 7) MessagePlayer("Command level too high", player);Fixed anyways player.Level() < 7 means it cant be used by a person lower than lvl 7.
It wont work because afaik Player.Level is not a Squirrel function. you better check it on Blank script before posting in VCMP community because there are many newbies those copy snippets and after getting error because of a broken script or their weak brain they start spamming the forum
Ok then simply replace with this:
plrlevel = GetLevel( nick );
else if (plrlevel > 7) MessagePlayer("Command level too high", player);
That good?
Title: Re: Forcing Spawn/Eject.
Post by: . on Jan 17, 2016, 08:26 PM
@{ultimatejugo] Can you show me the contents of your GetLevel() function? Me and a few guys have a curiosity about it.
Title: Re: Forcing Spawn/Eject.
Post by: [VM_U]Spectra.PhantoM^ on Jan 17, 2016, 08:28 PM
Quote from: S.L.C on Jan 17, 2016, 08:26 PM@{ultimatejugo] Can you show me the contents of your GetLevel() function? Me and a few guys have a curiosity about it.
Whats there to show? anyways ill post soon in another snippet until then.
BE CURIOUS!
Title: Re: Forcing Spawn/Eject.
Post by: Anik on Jan 18, 2016, 03:55 AM
LOL only 2 lines which is of work in the both snippet
1
plr.Eject();2
plr.Spawn();Clap Clap Clap CLap..............
Title: Re: Forcing Spawn/Eject.
Post by: EK.IceFlake on Jan 18, 2016, 04:33 AM
You don't even use the veh variable you created in force eject. Also I noticed this is in Doomplay format, you can take the functions from there. And either you edited emessage or its plain wrong, because its not in that format. You need to have a type (Msgtype.Info, Msgtype.Command or Msgtype.Error)
Title: Re: Forcing Spawn/Eject.
Post by: [VM_U]Spectra.PhantoM^ on Jan 18, 2016, 01:19 PM
@S.L.C  I posted the function u wer curious about.
Title: Re: Forcing Spawn/Eject.
Post by: MacTavish on Jan 18, 2016, 01:36 PM
There is No Builtin Function that could check player level check the WIKI (http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions#Player_Functions) And you have right to slap me if i am wrong for f*** sake please check the wiki once
Title: Re: Forcing Spawn/Eject.(UPDATED)
Post by: [VM_U]Spectra.PhantoM^ on Jan 18, 2016, 01:41 PM
Quote from: Kusanagi on Jan 18, 2016, 01:36 PMThere is No Builtin Function that could check player level check the WIKI (http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions#Player_Functions) And you have right to slap me if i am wrong for f*** sake please check the wiki once
I didnt mean a builtin function anyways -_- i just posted the function and the whole thing Afaik. :P
Title: Re: Forcing Spawn/Eject.(UPDATED)
Post by: KAKAN on Jan 18, 2016, 01:43 PM
Quote from: {ultimatejugo} on Jan 18, 2016, 01:41 PM
Quote from: Kusanagi on Jan 18, 2016, 01:36 PMThere is No Builtin Function that could check player level check the WIKI (http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions#Player_Functions) And you have right to slap me if i am wrong for f*** sake please check the wiki once
I didnt mean a builtin function anyways -_- i just posted the function and the whole thing Afaik. :P
the index 'db' doesn't exist
the index 'GetSQLColumnData' doesn't exist
the index 'QuerySQL' doesn't exist
Please fix them!
Title: Re: Forcing Spawn/Eject.(UPDATED)
Post by: MacTavish on Jan 18, 2016, 01:46 PM
Quote from: {ultimatejugo on Jan 18, 2016, 01:41 PM
Quote from: Kusanagi on Jan 18, 2016, 01:36 PMThere is No Builtin Function that could check player level check the WIKI (http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions#Player_Functions) And you have right to slap me if i am wrong for f*** sake please check the wiki once
I didnt mean a builtin function anyways -_- i just posted the function and the whole thing Afaik. :P

that is not whole thing how do you know everyone have that table in their script and how they are assigning levels to player and how they are checking. I will suggest to remove that line just add a simple comment there

// Put your level checking line here
this simple line will solve the trouble. Dont Ever Act Smarter that other because it doesnt matter how long you have been played vcmp it matters to how much you learned from vcmp
Title: Re: Forcing Spawn/Eject.(UPDATED)
Post by: . on Jan 18, 2016, 02:16 PM
Quote from: {ultimatejugo] on Jan 18, 2016, 01:19 PM@S.L.C  I posted the function u wer curious about.

You just confirmed my curiosity. The fact that you query the database each time you need the player level ;D
Title: Re: Forcing Spawn/Eject.(UPDATED)
Post by: EK.IceFlake on Jan 18, 2016, 03:15 PM
Quote from: KAKAN on Jan 18, 2016, 01:43 PM
Quote from: {ultimatejugo} on Jan 18, 2016, 01:41 PM
Quote from: Kusanagi on Jan 18, 2016, 01:36 PMThere is No Builtin Function that could check player level check the WIKI (http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions#Player_Functions) And you have right to slap me if i am wrong for f*** sake please check the wiki once
I didnt mean a builtin function anyways -_- i just posted the function and the whole thing Afaik. :P
the index 'db' doesn't exist
the index 'GetSQLColumnData' doesn't exist
the index 'QuerySQL' doesn't exist
Please fix them!
use SQLite plugin
onscriptload:
db <- ConnectSQL("database.sqli");
Title: Re: Forcing Spawn/Eject.(UPDATED)
Post by: [VM_U]Spectra.PhantoM^ on Jan 18, 2016, 03:25 PM
Quote from: Kusanagi on Jan 18, 2016, 01:46 PM
Quote from: {ultimatejugo on Jan 18, 2016, 01:41 PM
Quote from: Kusanagi on Jan 18, 2016, 01:36 PMThere is No Builtin Function that could check player level check the WIKI (http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions#Player_Functions) And you have right to slap me if i am wrong for f*** sake please check the wiki once
I didnt mean a builtin function anyways -_- i just posted the function and the whole thing Afaik. :P

that is not whole thing how do you know everyone have that table in their script and how they are assigning levels to player and how they are checking. I will suggest to remove that line just add a simple comment there

// Put your level checking line here
this simple line will solve the trouble. Dont Ever Act Smarter that other because it doesnt matter how long you have been played vcmp it matters to how much you learned from vcmp
i dont impress anybody nor do i want someone to think that i am pro or somting im just helping server owners.
Quote from: S.L.C on Jan 18, 2016, 02:16 PM
Quote from: {ultimatejugo] on Jan 18, 2016, 01:19 PM@S.L.C  I posted the function u wer curious about.

You just confirmed my curiosity. The fact that you query the database each time you need the player level ;D
thats the way to go ;D
Title: Re: Forcing Spawn/Eject.(UPDATED)
Post by: . on Jan 18, 2016, 04:53 PM
Quote from: {ultimatejugo] on Jan 18, 2016, 03:25 PMthats the way to go ;D

I'm not sure how your brain works but mine says that anything involving frequent execution should stay away from IO operations on disk. Especially those involving the compilation of a query/statement and actually doing multiple IO operations on disk. Can you even imagine the IO stress that a server goes through when multiple VPSs are doing that simultaneously? On your computer it doesn't seem like much since there's only one person using that computer. But imagine 10,20 people using that computer and some of them hosting web servers which are high on IO operations for fetching resources (unless caching software is used). And here you are doing the worst thing that one can imagine. I'm not sure if you're sarcastic or just plain arrogant but you should stop from posting crap that doesn't make sense. It doesn't make you look cool. In fact, it does the opposite.

No one is asking you to be some pro level programmer but FFS go and actually read some documentation before using something you have no idea about. It makes you look stupid when you don't.
Title: Re: Forcing Spawn/Eject.(UPDATED)
Post by: [VM_U]Spectra.PhantoM^ on Jan 18, 2016, 04:56 PM
Quote from: S.L.C on Jan 18, 2016, 04:53 PM
Quote from: {ultimatejugo] on Jan 18, 2016, 03:25 PMthats the way to go ;D

I'm not sure how your brain works but mine says that anything involving frequent execution should stay away from IO operations on disk. Especially those involving the compilation of a query/statement and actually doing multiple IO operations on disk. Can you even imagine the IO stress that a server goes through when multiple VPSs are doing that simultaneously? On your computer it doesn't seem like much since there's only one person using that computer. But imagine 10,20 people using that computer and some of them hosting web servers which are high on IO operations for fetching resources (unless caching software is used). And here you are doing the worst thing that one can imagine. I'm not sure if you're sarcastic or just plain arrogant but you should stop from posting crap that doesn't make sense. It doesn't make you look cool. In fact, it does the opposite.

No one is asking you to be some pro level programmer but FFS go and actually read some documentation before using something you have no idea about. It makes you look stupid when you don't.
Dont u understand sarcasm? or what?