[NoN]Bruno
05-01-2009, 02:28 PM
Hi all, im [NoN]Bruno and i been scripting some functions for VCO. Here they are:
Heal player:
function healme(PlayerID,Health)
if getPlayerHealth(PlayerID) == 100 then
outputChatBox(PlayerID,"Error: Your HP is already 100",255,0,0,255)
return end
if getPlayerHealth(PlayerID) < 99 then
setPlayerHealth(PlayerID,100)
setPlayerArmour(PlayerID,100)
outputChatBox(PlayerID,"Your are now healed.",0,255,0,255)
return end
end
addCommand("heal","healme")
Repair car:
function RepairVehicle(PlayerID,VehicleID)
if isPlayerInAnyVehicle(PlayerID) == 1 then
VehicleID = getPlayerVehicleID(PlayerID)
repairVehicle(VehicleID)
setVehicleHealth(VehicleID,10000)
outputChatBox(PlayerID,"Repaired.",0,255,0,255)
else outputChatBox(PlayerID,"Your on foot!",255,0,0,255) return end
end
addCommand("repair","RepairVehicle")
Set weather:
function SetWeather(PlayerID,WeatherID)
if WeatherID == nil then
outputChatBox(PlayerID,"The ID must be between 0 and 5.",255,0,0,255) return end
setServerWeather(WeatherID)
outputChatBox(PlayerID,"Done." .. WeatherID,0,255,0,255)
end
addCommand("setweather","SetWeather")
This are 2 functions , they are both required to make the second one work!.
This creates a ramp in front of player:
function GetXYInFrontOfPlayer(PlayerID,Radius)
local X,Y,Z = getPlayerPos(PlayerID)
local a = getPlayerAngle(PlayerID)
X = X + ((math.cos(math.rad(a) + (math.pi/ 2)))*(Radius))
Y = Y + ((math.sin(math.rad(a) + (math.pi/ 2)))*(Radius))
return X,Y,Z,a
end
function onPlayerKeyPress(PlayerID,KeyID)
if KeyID == 90 then --This is Z.
if isPlayerInAnyVehicle(PlayerID) == 0 then
return end
local XPos, YPos, ZPos = getPlayerPos(PlayerID)
local XAngle, YAngle, ZAngle = 0, 0, getPlayerAngle(PlayerID)
local InteriorID = getPlayerInterior(PlayerID)
XPos, YPos, ZPos = GetXYInFrontOfPlayer( PlayerID, 20 )
createGlobalObject(583, XPos, YPos, ZPos, XAngle, YAngle, ZAngle, InteriorID)
local GlobalObject = ObjectID
delay(1000)
destroyGlobalObject(ObjectID)
return end
end
You can change the KeyID by checking the number here: CLICK ME!l (http://livedocs.adobe.com/flash/8/main/wwhelp/wwh impl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001686.html)
Its like the one abs playground has in their script.Its fun to use.You can change
XPos, YPos, ZPos = GetXYInFrontOfPlayer( PlayerID, 20 )
That number so it spawns far or near to the player.
delay(1000)
The 1000 is the time that the functions stops ( In ms ). There is an error in here, you can create another ramp between the 1000 ms that i set.You i'll have to wait.
Since this is a callback you can add more functions to it. Just remove the "end" and then add this :
This creates a PCJ 600 near player:
if KeyID == 69 then
local XPos, YPos, ZPos = getPlayerPos(PlayerID)
local XAngle, YAngle, ZAngle = 0, 0, getPlayerAngle(PlayerID)
XPos, YPos, ZPos = GetXYInFrontOfPlayer( PlayerID, 10 )
createVehicle(191,XPos,YPos,ZPos,ZAngle,0,0)
return end
This creates a Cheetta in fron of player:
if KeyID == 81 then
local XPos, YPos, ZPos = getPlayerPos(PlayerID)
local XAngle, YAngle, ZAngle = 0, 0, getPlayerAngle(PlayerID)
XPos, YPos, ZPos = GetXYInFrontOfPlayer( PlayerID, 10 )
createVehicle(145,XPos,YPos,ZPos,ZAngle,0,0)
return end
-- End of OnPlayerKeyPress callback --
This is actually pretty fun, its Mex's function , but i gave him the idea ( This creates an explosion on player's pos , you can change the explosion ID, but ID 6 is default ) :
addCommand("e", "e")
function e(PlayerID, Type)
if isPlayerSpawned(PlayerID) == 0 then return end
local TypeID = 6
if Type and tonumber(Type) then TypeID = tonumber(Type) end
local X, Y, Z = getPlayerPos(PlayerID)
createExplosion(X, Y, Z, TypeID)
end
Thats all, im gonna continue scripting. Thanks to Mex and ReGex for doing the GetXYInFrontOfPlayer :) :)
Thanks!
Heal player:
function healme(PlayerID,Health)
if getPlayerHealth(PlayerID) == 100 then
outputChatBox(PlayerID,"Error: Your HP is already 100",255,0,0,255)
return end
if getPlayerHealth(PlayerID) < 99 then
setPlayerHealth(PlayerID,100)
setPlayerArmour(PlayerID,100)
outputChatBox(PlayerID,"Your are now healed.",0,255,0,255)
return end
end
addCommand("heal","healme")
Repair car:
function RepairVehicle(PlayerID,VehicleID)
if isPlayerInAnyVehicle(PlayerID) == 1 then
VehicleID = getPlayerVehicleID(PlayerID)
repairVehicle(VehicleID)
setVehicleHealth(VehicleID,10000)
outputChatBox(PlayerID,"Repaired.",0,255,0,255)
else outputChatBox(PlayerID,"Your on foot!",255,0,0,255) return end
end
addCommand("repair","RepairVehicle")
Set weather:
function SetWeather(PlayerID,WeatherID)
if WeatherID == nil then
outputChatBox(PlayerID,"The ID must be between 0 and 5.",255,0,0,255) return end
setServerWeather(WeatherID)
outputChatBox(PlayerID,"Done." .. WeatherID,0,255,0,255)
end
addCommand("setweather","SetWeather")
This are 2 functions , they are both required to make the second one work!.
This creates a ramp in front of player:
function GetXYInFrontOfPlayer(PlayerID,Radius)
local X,Y,Z = getPlayerPos(PlayerID)
local a = getPlayerAngle(PlayerID)
X = X + ((math.cos(math.rad(a) + (math.pi/ 2)))*(Radius))
Y = Y + ((math.sin(math.rad(a) + (math.pi/ 2)))*(Radius))
return X,Y,Z,a
end
function onPlayerKeyPress(PlayerID,KeyID)
if KeyID == 90 then --This is Z.
if isPlayerInAnyVehicle(PlayerID) == 0 then
return end
local XPos, YPos, ZPos = getPlayerPos(PlayerID)
local XAngle, YAngle, ZAngle = 0, 0, getPlayerAngle(PlayerID)
local InteriorID = getPlayerInterior(PlayerID)
XPos, YPos, ZPos = GetXYInFrontOfPlayer( PlayerID, 20 )
createGlobalObject(583, XPos, YPos, ZPos, XAngle, YAngle, ZAngle, InteriorID)
local GlobalObject = ObjectID
delay(1000)
destroyGlobalObject(ObjectID)
return end
end
You can change the KeyID by checking the number here: CLICK ME!l (http://livedocs.adobe.com/flash/8/main/wwhelp/wwh impl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001686.html)
Its like the one abs playground has in their script.Its fun to use.You can change
XPos, YPos, ZPos = GetXYInFrontOfPlayer( PlayerID, 20 )
That number so it spawns far or near to the player.
delay(1000)
The 1000 is the time that the functions stops ( In ms ). There is an error in here, you can create another ramp between the 1000 ms that i set.You i'll have to wait.
Since this is a callback you can add more functions to it. Just remove the "end" and then add this :
This creates a PCJ 600 near player:
if KeyID == 69 then
local XPos, YPos, ZPos = getPlayerPos(PlayerID)
local XAngle, YAngle, ZAngle = 0, 0, getPlayerAngle(PlayerID)
XPos, YPos, ZPos = GetXYInFrontOfPlayer( PlayerID, 10 )
createVehicle(191,XPos,YPos,ZPos,ZAngle,0,0)
return end
This creates a Cheetta in fron of player:
if KeyID == 81 then
local XPos, YPos, ZPos = getPlayerPos(PlayerID)
local XAngle, YAngle, ZAngle = 0, 0, getPlayerAngle(PlayerID)
XPos, YPos, ZPos = GetXYInFrontOfPlayer( PlayerID, 10 )
createVehicle(145,XPos,YPos,ZPos,ZAngle,0,0)
return end
-- End of OnPlayerKeyPress callback --
This is actually pretty fun, its Mex's function , but i gave him the idea ( This creates an explosion on player's pos , you can change the explosion ID, but ID 6 is default ) :
addCommand("e", "e")
function e(PlayerID, Type)
if isPlayerSpawned(PlayerID) == 0 then return end
local TypeID = 6
if Type and tonumber(Type) then TypeID = tonumber(Type) end
local X, Y, Z = getPlayerPos(PlayerID)
createExplosion(X, Y, Z, TypeID)
end
Thats all, im gonna continue scripting. Thanks to Mex and ReGex for doing the GetXYInFrontOfPlayer :) :)
Thanks!