Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- // //
- // Vice-city Squirrel Extension 0.1b //
- // By: [R3V]PlayerX //
- // //
- // 0.1b VSE-Main: //
- // Added Events //
- // VSE_CallEventInExtension() //
- // VSE_LoadModules() //
- // VSE_LoadFiles() //
- // VSE_IsNum() //
- // VSE_Value() //
- // VSE_AddEvent() //
- // VSE_CallFunction() //
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- local VSE_Modules_Loades = 0;
- local VSE_Files_Loades = 0;
- local VSE_Event = {};
- for(local v = 0; v < 42; v++)
- {
- VSE_Event[v] <- {};
- }
- VSE_Events <- ["onServerStart", "onTimeChange", "onWeatherChange", "onScriptLoad", "onScriptUnload", "onConsoleInput", "onPlayerJoin", "onPlayerPart" , "onPlayerSpawn", "onPlayerDeath", "onPlayerKill", "onPlayerTeamKill", "onPlayerChat", "onPlayerAction", "onPlayerPM", "onPlayerFailedPM", "onPlayerTeamChat", "onPlayerCommand", "onPlayerHealthChange", "onPlayerArmourChange", "onPlayerWeaponChange", "onPlayerCashChange", "onPlayerScoreChange", "onPlayerKeyStateChange", "onPlayerMove", "onPlayerRequestClass", "onPlayerRequestAmmunation", "onPlayerRequestAmmuWeapon", "onPlayerStartSpectating", "onPlayerExitSpectating", "onPlayerRconLogin", "onPlayerRconLoginAttempt", "onPlayerFall", "onPlayerVersion", "onPlayerEnterVehicle", "onPlayerExitVehicle", "onVehicleHealthChange", "onVehicleRespawn", "onVehicleMove", "onPickupPickedUp", "onPickupDestroy", "onPickupRespawn"];
- ///////////////////////////////////////////////////////////////////////////////////
- function onServerStart()
- {
- print("[VSE] Loading Files...");
- VSE_CallEventInExtension(VSE_Events[0]);
- return 1;
- }
- function onScriptLoad()
- {
- print(">>==============================================<<");
- print(">>========// VLE 0.1b by [R3V]PlayerX //========<<");
- print(">>==============// Loading... //================<<");
- VSE_Modules_Loades = VSE_LoadModules();
- VSE_Files_Loades = VSE_LoadFiles();
- print(">>===============|| Finished ||=================<<");
- print(">>======|| Modules Loades: " + VSE_Modules_Loades.tostring() + " ||==========<<");
- print(">>======|| Files Loades: " + VSE_Files_Loades.tostring() + " ||=========<<");
- print(">>==============================================<<");
- VSE_CallEventInExtension(VSE_Events[3]);
- return 1;
- }
- function onTimeChange(hour, minute)
- {
- VSE_CallEventInExtension(VSE_Events[1], hour, minute );
- return 1;
- }
- function onWeatherChange(oldw, neww)
- {
- VSE_CallEventInExtension(VSE_Events[2], oldw, neww );
- return 1;
- }
- function onScriptUnload()
- {
- VSE_CallEventInExtension(VSE_Events[4]);
- return 1;
- }
- function onConsoleInput(cmd, text)
- {
- VSE_CallEventInExtension(VSE_Events[5], cmd, text);
- return 1;
- }
- function onPlayerJoin(player)
- {
- VSE_CallEventInExtension(VSE_Events[6], player);
- return 1;
- }
- function onPlayerPart(player, reason)
- {
- VSE_CallEventInExtension(VSE_Events[7], player, reason);
- return 1;
- }
- function onPlayerSpawn(player)
- {
- VSE_CallEventInExtension(VSE_Events[8], player);
- return 1;
- }
- function onPlayerDeath(player, reason)
- {
- VSE_CallEventInExtension(VSE_Events[9], player, reason);
- return 1;
- }
- function onPlayerKill(killer, player, reason, bodypart)
- {
- VSE_CallEventInExtension(VSE_Events[10], killer, player, reason, bodypart);
- return 1;
- }
- function onPlayerTeamKill(killer, player, reason, bodypart)
- {
- VSE_CallEventInExtension(VSE_Events[11], killer, player, reason, bodypart);
- return 1;
- }
- function onPlayerChat(player, text)
- {
- VSE_CallEventInExtension(VSE_Events[12], player, text);
- return 1;
- }
- function onPlayerAction(player, text)
- {
- VSE_CallEventInExtension(VSE_Events[13], player, text);
- return 1;
- }
- function onPlayerPM(player1, player2, text)
- {
- VSE_CallEventInExtension(VSE_Events[14], player1, player2, text);
- return 1;
- }
- function onPlayerFailedPM(player1, player2, text)
- {
- VSE_CallEventInExtension(VSE_Events[15], player1, player2, text);
- return 1;
- }
- function onPlayerTeamChat(player1, player2, text)
- {
- VSE_CallEventInExtension(VSE_Events[16], player1, player2, text);
- return 1;
- }
- function onPlayerCommand(player, cmd, text)
- {
- VSE_CallEventInExtension(VSE_Events[17], player, cmd, text);
- return 1;
- }
- function onPlayerHealthChange(player, oldhp, newhp)
- {
- VSE_CallEventInExtension(VSE_Events[18], player, oldhp, newhp);
- return 1;
- }
- function onPlayerArmourChange(player, oldarm, newarm)
- {
- VSE_CallEventInExtension(VSE_Events[19], player, oldarm, newarm);
- return 1;
- }
- function onPlayerWeaponChange(player, oldwep, newwep)
- {
- VSE_CallEventInExtension(VSE_Events[20], player, oldwep, newwep);
- return 1;
- }
- function onPlayerCashChange(player, oldcash, newcash)
- {
- VSE_CallEventInExtension(VSE_Events[21], player, oldcash, newcash);
- return 1;
- }
- function onPlayerScoreChange(player, oldscore, newscore)
- {
- VSE_CallEventInExtension(VSE_Events[22], player, oldscore, newscore);
- return 1;
- }
- function onPlayerKeyStateChange(player, key, down)
- {
- VSE_CallEventInExtension(VSE_Events[23], player, key, down);
- return 1;
- }
- function onPlayerMove(player, x1, y1, z1, x2, y2, z2)
- {
- VSE_CallEventInExtension(VSE_Events[24], player, x1, y1, z1, x2, y2, z2);
- return 1;
- }
- function onPlayerRequestClass(player, id, team, skin)
- {
- VSE_CallEventInExtension(VSE_Events[25], player, id, team, skin);
- return 1;
- }
- function onPlayerRequestAmmunation(player, ammunationid)
- {
- VSE_CallEventInExtension(VSE_Events[26], player, ammunationid);
- return 1;
- }
- function onPlayerRequestAmmuWeapon(player, ammunationid, weaponid)
- {
- VSE_CallEventInExtension(VSE_Events[27], player, ammunationid, weaponid);
- return 1;
- }
- function onPlayerStartSpectating(player1, player2)
- {
- VSE_CallEventInExtension(VSE_Events[28], player1, player2);
- return 1;
- }
- function onPlayerExitSpectating(player)
- {
- VSE_CallEventInExtension(VSE_Events[29], player);
- return 1;
- }
- function onPlayerRconLogin(player)
- {
- VSE_CallEventInExtension(VSE_Events[30], player);
- return 1;
- }
- function onPlayerRconLoginAttempt(player, pass)
- {
- VSE_CallEventInExtension(VSE_Events[31], player, pass);
- return 1;
- }
- function onPlayerFall(player)
- {
- VSE_CallEventInExtension(VSE_Events[32], player);
- return 1;
- }
- function onPlayerVersion(player, version)
- {
- VSE_CallEventInExtension(VSE_Events[33], player, version);
- return 1;
- }
- function onPlayerEnterVehicle(player, vehicle, passenger)
- {
- VSE_CallEventInExtension(VSE_Events[34], player, vehicle, passenger);
- return 1;
- }
- function onPlayerExitVehicle(player, vehicle, passenger)
- {
- VSE_CallEventInExtension(VSE_Events[35], player, vehicle, passenger);
- return 1;
- }
- function onVehicleHealthChange(vehicle, oldhp, newhp)
- {
- VSE_CallEventInExtension(VSE_Events[36], vehicle, oldhp, newhp);
- return 1;
- }
- function onVehicleRespawn(vehicle)
- {
- VSE_CallEventInExtension(VSE_Events[37], vehicle);
- return 1;
- }
- function onVehicleMove(player, vehicle, x1, y1, z1, x2, y2, z2)
- {
- VSE_CallEventInExtension(VSE_Events[38], player, vehicle, x1, y1, z1, x2, y2, z2);
- return 1;
- }
- function onPickupPickedUp(player, pickup)
- {
- VSE_CallEventInExtension(VSE_Events[39], player, pickup);
- return 1;
- }
- function onPickupDestroy(pickup)
- {
- VSE_CallEventInExtension(VSE_Events[40], pickup);
- return 1;
- }
- function onPickupRespawn(pickup)
- {
- VSE_CallEventInExtension(VSE_Events[41], pickup);
- return 1;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////
- function VSE_LoadModules()
- {
- local total = 0;
- if(!VSE_FileExists("Modules.ini")) return 0;
- local FileHandle = file("Modules.ini", "r");
- if(FileHandle)
- {
- local result = "";
- while(!FileHandle.eos())
- {
- local c = FileHandle.readn('c');
- result = "" + result + "" + c.tochar();
- }
- if(result.len() > 0)
- {
- local m = split(result, "\r\n");
- foreach(i, instance in m)
- {
- local s = split(m[i], " ");
- if(s[1].tostring() == "1")
- {
- LoadModule(s[0]);
- total++;
- }
- }
- return total;
- }
- }
- return 0;
- }
- function VSE_FileExists(FilePath)
- {
- try
- {
- file(FilePath, "r");
- }
- catch(E) return 0;
- return 1;
- }
- function VSE_LoadFiles()
- {
- local total = 0;
- if(!VSE_FileExists("Files.ini")) return 0;
- local FileHandle = file("Files.ini", "r");
- if(FileHandle)
- {
- local result = "";
- while(!FileHandle.eos())
- {
- local c = FileHandle.readn('c');
- result = "" + result + "" + c.tochar();
- }
- local s = split(result, "\r\n");
- foreach(i, instance in s)
- {
- local f = split(s[i], " ");
- if(f[1].tostring() == "1")
- {
- dofile("" + f[0] + ".nut");
- total++;
- }
- }
- return total;
- }
- return 0;
- }
- function VSE_CallEventInExtension(EventName, ...)
- {
- foreach(p, event in VSE_Events)
- {
- if(EventName == event)
- {
- foreach(i, func in VSE_Event[p])
- {
- local line;
- local moo;
- if(!vargv.len()) moo = compilestring(VSE_Event[p][i] + "()");
- else
- {
- for(local i = 0; i< vargv.len(); i++)
- {
- if(!line) line = VSE_Value(vargv[i].tostring());
- else line = line + "," + VSE_Value(vargv[i].tostring());
- }
- moo = compilestring(VSE_Event[p][i] + "(" + line + ")");
- }
- moo();
- }
- }
- }
- }
- function VSE_CallFunction(string,...)
- {
- local line;
- local moo;
- if(!vargv.len()) moo = compilestring(string + "()");
- else
- {
- for(local i = 0; i< vargv.len(); i++)
- {
- if(!line) line = VSE_Value(vargv[i].tostring());
- else line = line + "," + VSE_Value(vargv[i].tostring());
- }
- moo = compilestring(string + "(" + line + ")");
- }
- moo();
- }
- function VSE_AddEvent(EventName, f)
- {
- foreach(i, event in VSE_Events)
- {
- if(EventName == event)
- {
- foreach(i2, func in VSE_Event[i])
- {
- if(f == VSE_Event[i][i2]) return print("[VSE] Error: function already exists.");
- else
- {
- VSE_Event[i][VSE_Event[i].len()] <- f;
- return 1;
- }
- }
- VSE_Event[i][VSE_Event[i].len()] <- f;
- return 1;
- }
- }
- return print("[VSE] Invalid Event Name: " + EventName)
- }
- function VSE_DelEvent(EventName, f)
- {
- foreach(i, event in VSE_Events)
- {
- if(EventName == event)
- {
- VSE_Event[i][VSE_Event[i].len()] <- f;
- return 1;
- }
- }
- }
- function VSE_Value(data)
- {
- local d = VSE_IsNum(data);
- if(d == 0) return format("\"%s\"", data);
- else if(d == 1) return data.tointeger();
- else if(d == 2) return data.tofloat();
- else return data;
- }
- function VSE_IsNum(data)
- {
- local _a = 1;
- foreach(i, char in data)
- {
- if(char > 47 && char < 58) continue;
- else if(char == 46) _a = 2;
- else _a = 0;
- }
- return _a;
- }
- VSE_AddEvent("onTimeChange", "x");
- VSE_AddEvent("onTimeChange", "y");
- function x(hour, minute)
- {
- print(">> " + hour + ":" + minute);
- return 1;
- }
- function y(hour, minute)
- {
- print(">> " + hour + ":" + minute);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement