wiki is not 100% updated for that, there are some issues..
what is the true function for set the speed individually?
what is the true function for set the speed individually?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts MenuQuoteif ( !IsNum( text ) ) aMsg( id, "Invalid vehicle id." )the function "IsNum" was not added on the plugin's inside (squirrel plugin)
Class PlayerInfo {
Team = false;
Request = false;
TimeRequest = 0;
Partner = null;
}
function onScriptLoad()
{
pinfo <- array( GetMaxPlayers(), null );
}
function onPlayerJoin( player )
{
pinfo[ player.ID ] = PlayerInfo();
}
function onPlayerSpawn( player )
{
if ( pinfo[ player.ID ].Team == true )
{
local plr = FindPlayer( pinfo[ player.ID ].Partner );
if ( plr ) player.Pos = plr.Pos;
}
}
function onPlayerPart( player, reason )
{
if ( pinfo[ player.ID ].Team == true )
{
local plr = FindPlayer( pinfo[ player.ID ].Partner );
if ( plr ) {
PrivMessage( plr, "[!] " + player.Name + " left the team." );
pinfo[ plr.ID ].Partner = null;
pinfo[ plr.ID ].Team = false;
}
}
pinfo[ player.ID ] = null;
}
function onPlayerSpawn( player )
{
if ( pinfo[ player.ID ].Team == true )
{
local plr = FindPlayer( pinfo[ player.ID ].Partner );
if ( plr ) player.Pos = plr.Pos;
}
}
// Version no.1
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();
}
// Version no.2
function GetTok(str, sep, pos, len = null)
{
if (typeof str != "string" || str.len() < 1) return "";
else if (typeof sep != "string" || sep.len() < 1) return "";
local tok = split(str, sep);
if (typeof tok != "array") return str;
else if (tok.len() == 1 && tok[0] == str) return tok[0];
if (typeof pos != "integer")
{
if (typeof pos == "float" || typeof pos == "string") pos = pos.tointeger();
else return "";
}
if (pos >= tok.len()) return "";
else if (pos < 0) pos = 0;
if (len == null)
len = (tok.len() - pos);
else if (typeof len != "integer")
{
if (typeof len == "float" || typeof len == "string") len = len.tointeger();
else return "";
}
if ((pos+len) > tok.len()) len = (tok.len() - pos);
else if (len <= 0) return "";
tok = tok.slice(pos, pos+len);
if (tok.len() > 1)
{
local res = tok[0];
tok.remove(0);
foreach (tk in tok) res += sep + tk;
return res;
}
else if (tok.len() == 1) return tok[0];
else return "";
}
function NumTok(str, sep)
{
if (typeof str != "string" || str.len() < 1) return 0;
else if (typeof sep != "string" || sep.len() < 1) return 0;
local tok = split(str, sep);
if (typeof tok != "array") return 0;
else if (tok.len() == 1 && tok[0] == str) return 0;
else return tok.len();
}
function onPlayerCommand( player, cmd, text )
{
local plr, i = 0;
if ( text ) {
plr = FindPlayer( text );
i = NumTok(text, " ").tointeger();
}
if ( cmd == "team" )
{
local plr = FindPlayer( GetTok( text, " ", 1 ) );
if ( pinfo[ player.ID ].Team == true ) PrivMessage( player, "[Error] You already have a team." );
else if ( !text ) PrivMessage( player, "Syntax: /team <player name or id>" );
else if ( !plr ) PrivMessage( player, "[Error] Unknown player." );
else if ( pinfo[ plr.ID ].Team == true ) PrivMessage( player, "[Error] " + plr.Name + " is already in a team." );
else if ( pinfo[ player.ID ].Request == true ) PrivMessage( player, "[Error] You already have a request." );
else if ( pinfo[ plr.ID ].Request == true ) PrivMessage( player, "[Error] " + plr.Name + " already have a request." );
else
{
if ( pinfo[ player.ID ].TimeRequest < time() ) {
pinfo[ player.ID ].Request = false; pinfo[ player.ID ].Partner = null; pinfo[ player.ID ].TimeRequest = 0;
pinfo[ plr.ID ].Request = false; pinfo[ plr.ID ].Partner = null; pinfo[ plr.ID ].TimeRequest = 0;
}
PrivMessage( plr, "[!] " + player.Name + " would like to team up with you." );
PrivMessage( player, "Request submitted." );
pinfo[ player.ID ].Partner = plr;
pinfo[ plr.ID ].Partner = player;
pinfo[ player.ID ].TimeRequest = time() + 30;
pinfo[ plr.ID ].TimeRequest = time() + 30;
pinfo[ plr.ID ].Request = true;
pinfo[ player.ID ].Request = true;
}
}
else if ( cmd == "accept" )
{
local plr = FindPlayer( pinfo[ player.ID ].Partner );
if ( pinfo[ player.ID ].Request == false ) PrivMessage( player, "[Error] You don't have a request." );
else if ( pinfo[ player.ID ].Team == true ) PrivMessage( player, "[Error] You already have a team-mate." );
else
{
if ( pinfo[ player.ID ].TimeRequest < time() ) {
PrivMessage( player, "[Error] Time ended." );
pinfo[ player.ID ].Request = false;
pinfo[ player.ID ].Partner = null;
pinfo[ plr.ID ].Request = false;
pinfo[ plr.ID ].Partner = null;
pinfo[ player.ID ].TimeRequest = 0;
pinfo[ plr.ID ].TimeRequest = 0;
} else {
PrivMessage( plr, "[!] " + player.Name + " is doing team with you." );
PrivMessage( player, "Request Accepted! You are now teaming with " + plr.Name );
pinfo[ player.ID ].Team = true;
pinfo[ plr.ID ].Team = true;
pinfo[ player.ID ].Request = false;
pinfo[ plr.ID ].Request = false;
pinfo[ player.ID ].TimeRequest = 0;
pinfo[ plr.ID ].TimeRequest = 0;
player.Pos = plr.Pos;
}
}
}
else if ( cmd == "deny" )
{
if ( pinfo[ player.ID ].Request == false ) PrivMessage( player, "[Error] You don't have a request." );
else
{
local plr = FindPlayer( pinfo[ player.ID ].Partner );
if ( pinfo[ player.ID ].TimeRequest < time() ) {
PrivMessage( player, "[Error] Time ended." );
pinfo[ player.ID ].Request = false;
pinfo[ plr.ID ].Request = false;
pinfo[ player.ID ].Partner = null;
pinfo[ plr.ID ].Partner = null;
pinfo[ player.ID ].TimeRequest = 0;
pinfo[ plr.ID ].TimeRequest = 0;
} else {
PrivMessage( plr, "[!] " + plr.Name + " denied your request." );
PrivMessage( player, "Request Denied." );
pinfo[ player.ID ].Request = false;
pinfo[ plr.ID ].Request = false;
pinfo[ player.ID ].TimeRequest = 0;
pinfo[ plr.ID ].TimeRequest = 0;
}
}
}
else if ( cmd == "leave" )
{
if ( pinfo[ player.ID ].Team == false ) PrivMessage( player, "[Error] You don't have team." );
else
{
local plr = FindPlayer( pinfo[ player.ID ].Partner );
PrivMessage( plr, "[!] " + player.Name + " left the team." );
PrivMessage( player, "You are not more team of " + plr.Name );
pinfo[ player.ID ].Team = false;
pinfo[ plr.ID ].Team = false;
pinfo[ player.ID ].Partner = null;
pinfo[ plr.ID ].Partner = null;
}
}
}