Goto, Heal And FixCar With Timer :D

Started by Mahmoud Tornado, Sep 11, 2017, 09:15 AM

Previous topic - Next topic

Mahmoud Tornado

Hi Friends Now I Was Testing New Files In My Server And When I End I Saw The Goto And Heal And Fix Commands Need Timers
So I Made Then With Some Help From @DarkRaZoR^ In NewTimer

Heal Command
else if ( cmd == "heal" )
{
if ( !player.IsSpawned ) MessagePlayer( "[#ff0000]Error - You haven't spawned yet..", player );
else if ( player.Health == 100 ) MessagePlayer( "[#ff0000]Error - You don't need to be healed", player );
else {
NewTimer( "heal", 3000, 1, player.ID );
Announce( "Healing...", player , 0 );
player.IsFrozen = true;
MessagePlayer( "[#ffbb00]You Will Be Healed In 3 Seconds.", player );
}
}

Heal Function
function heal(p)
{
local player = FindPlayer(p);
if (player) {
player.IsFrozen = false;
player.Health = 100;
MessagePlayer( "[#ffbb00]You Have Been Healed.", player );
}
}

Goto Command
else if ( cmd == "goto" )
{
if ( !text ) MessagePlayer( "[#ff0000]Syntax - /" + cmd + " <Player Nick/ID>", player );
else {
local plr = GetPlayer( text );
if ( !plr ) MessagePlayer( "[#ff0000]Error - Unknown Player..", player );
else if ( plr.ID == player.ID ) MessagePlayer( "[#ff0000]Error - You can't teleport to yourself!", player );
else if ( !plr.IsSpawned ) MessagePlayer( "[#ff0000]Error - The Player hasn't spawned yet..", player );
else {
NewTimer( "goto", 3000, 1, player.ID, plr.ID );
Announce( "Teleporting...", player , 0 );
player.IsFrozen = true;
MessagePlayer( "[#ffbb00]You Will Be Teleported In 3 Seconds To " + plr.Name + ". ", player);
}
}
}

Goto Function
function goto(player, plr)
{
player = FindPlayer( player );
plr = FindPlayer( plr );
if( player && plr )
{
Message( "[#25e805]Information: [#f2f2f2]" + player + " has teleported to " + plr + "." );
player.IsFrozen = false;
player.Pos = plr.Pos;
}
}

Fix Command
else if ( cmd == "fix" )
{
local veh = player.Vehicle;
if ( !veh ) MessagePlayer( "[#ff0000]Error - You must be in a Vehicle.", player );
else if ( veh.Health == 1000 ) MessagePlayer( "[#ff0000]Error - Your Vehicle is already fixed..", player );
else if ( veh.Health == 100 ) MessagePlayer( "[#ff0000]Error - Your Vehicle is already fixed..", player );
else {
Announce( "Fixing...", player , 0 );
player.IsFrozen = true;
NewTimer( "Fix", 3000, 1, player.ID );
MessagePlayer( "[#ffbb00]Your Car Will Be Fixed in 3 Seconds", player );
}
}

Fix Function
function Fix(p)
{
local player = FindPlayer(p);
if (player) {
local veh = player.Vehicle;
if(veh) {
player.IsFrozen = false;
player.Vehicle.Fix();
MessagePlayer( "[#ffbb00]Your Vehice Has Been Fixed", player );
}
}
}

Thx
MahmoudTornado.

D4rkR420R

#1
Quote from: Mahmoud Tornado on Sep 11, 2017, 09:15 AMGoto Function
function goto(player, plr)
{
player = FindPlayer( player );
plr = FindPlayer( plr );
if( player && plr )
{
Message( "[#25e805]Information: [#f2f2f2]" + player + " has teleported to " + plr + ".", player);
player.IsFrozen = false;
player.Pos = plr.Pos;
}
}

Fix Command
else if ( cmd == "fix" )
{
local veh = player.Vehicle;
if ( !veh ) MessagePlayer( "[#ff0000]Error - You must be in a Vehicle.", player );
else if ( veh.Health == 1000 ) MessagePlayer( "[#ff0000]Error - Your Vehicle is already fixed..", player );
else if ( veh.Health == 100 ) MessagePlayer( "[#ff0000]Error - Your Vehicle is already fixed..", player );
else {
Announce( "Fixing...", player , 0 );
player.IsFrozen = true;
NewTimer( "Fix", 3000, 1, player.ID );
MessagePlayer( "[#ffbb00]Your Car Will Be Fixed in 3 Seconds", player );
}
}

First of all, it's my plessure. Secondly, you missed the keywords local at your goto function. Furthermore, why did you include a if statemt defining if your vehicle has 100hp and 1000hp both in the code? Suggest to remove the one with 100hp since vehicles has a full of 1000hp.

Xmair

@DarkRaZoR^ there's no need for a local variable in his goto function.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Mahmoud Tornado

Quote from: DarkRaZoR^ on Sep 11, 2017, 04:38 PM
Quote from: Mahmoud Tornado on Sep 11, 2017, 09:15 AMGoto Function
function goto(player, plr)
{
player = FindPlayer( player );
plr = FindPlayer( plr );
if( player && plr )
{
Message( "[#25e805]Information: [#f2f2f2]" + player + " has teleported to " + plr + ".", player);
player.IsFrozen = false;
player.Pos = plr.Pos;
}
}

Fix Command
else if ( cmd == "fix" )
{
local veh = player.Vehicle;
if ( !veh ) MessagePlayer( "[#ff0000]Error - You must be in a Vehicle.", player );
else if ( veh.Health == 1000 ) MessagePlayer( "[#ff0000]Error - Your Vehicle is already fixed..", player );
else if ( veh.Health == 100 ) MessagePlayer( "[#ff0000]Error - Your Vehicle is already fixed..", player );
else {
Announce( "Fixing...", player , 0 );
player.IsFrozen = true;
NewTimer( "Fix", 3000, 1, player.ID );
MessagePlayer( "[#ffbb00]Your Car Will Be Fixed in 3 Seconds", player );
}
}

First of all, it's my plessure. Secondly, you missed the keywords local at your goto function. Furthermore, why did you include a if statemt defining if your vehicle has 100hp and 1000hp both in the code? Suggest to remove the one with 100hp since vehicles has a full of 1000hp.
Okay I UnderStood
Quote from: Xmair on Sep 11, 2017, 05:05 PM@DarkRaZoR^ there's no need for a local variable in his goto function.
Hmm Okay.

=RK=MarineForce

HEY Man i have to fixed this goto cmd

else if ( cmd == "goto" )
{
if ( !text ) MessagePlayer( "[#ff0000]Syntax - /" + cmd + " <Player Nick/ID>", player );
else {
local plr = FindPlayer( text );
if ( !plr ) MessagePlayer( "[#ff0000]Error - Unknown Player..", player );
else if ( plr.ID == player.ID ) MessagePlayer( "[#ff0000]Error - You can't teleport to yourself!", player );
else if ( !plr.IsSpawned ) MessagePlayer( "[#ff0000]Error - The Player hasn't spawned yet..", player );
else {
NewTimer( "goto", 3000, 1, player.ID, plr.ID );
Announce( "Teleporting...", player , 0 );
player.IsFrozen = true;
MessagePlayer( "[#ffbb00]You Will Be Teleported In 3 Seconds To " + plr.Name + ". ", player);
}
}
}

Change this Local plr = GetPlayer(text); to Local plr = FindPlayer ( text ); its work for me when i fixed it

Mahmoud Tornado

Quote from: =RK=MarineForce on May 11, 2018, 06:23 PMHEY Man i have to fixed this goto cmd

else if ( cmd == "goto" )
{
if ( !text ) MessagePlayer( "[#ff0000]Syntax - /" + cmd + " <Player Nick/ID>", player );
else {
local plr = FindPlayer( text );
if ( !plr ) MessagePlayer( "[#ff0000]Error - Unknown Player..", player );
else if ( plr.ID == player.ID ) MessagePlayer( "[#ff0000]Error - You can't teleport to yourself!", player );
else if ( !plr.IsSpawned ) MessagePlayer( "[#ff0000]Error - The Player hasn't spawned yet..", player );
else {
NewTimer( "goto", 3000, 1, player.ID, plr.ID );
Announce( "Teleporting...", player , 0 );
player.IsFrozen = true;
MessagePlayer( "[#ffbb00]You Will Be Teleported In 3 Seconds To " + plr.Name + ". ", player);
}
}
}

Change this Local plr = GetPlayer(text); to Local plr = FindPlayer ( text ); its work for me when i fixed it
As you don't have GetPlayer Function.
FindPlayer is an normal function.
The both work but you don't have GetPlayer Function.

=RK=MarineForce

#6
can u give me it ?

can some one give me getall cmd?

Mahmoud Tornado

Quote from: =RK=MarineForce on May 11, 2018, 08:01 PMcan u give me it ?
First GetPlayer Function
function GetPlayer( plr )
{
    if ( plr )
    {
        if ( IsNum( plr ) )
        {
            plr = FindPlayer( plr.tointeger() );
            if ( plr ) return plr;
            else return null;
        }
    else
        {     
            plr = FindPlayer( plr );
            if ( plr ) return plr;
            else return null;
        }
    }
    else return null;
}

Quote from: =RK=MarineForce on May 11, 2018, 08:01 PMcan some one give me getall cmd?
Second, if you want any thing, you Can ask here
https://forum.vc-mp.org/?board=37.0
But anyway here you are
else if ( cmd == "getall" )
{
if ( Stats[ player.ID ].Level < 4 ) MessagePlayer( "[#00de00]Inforamtion: [#fbf3f3]You are not authorized to use this command.", player );
else if ( Stats[ player.ID ].Log == false ) MessagePlayer( "[#00de00]Inforamtion: [#fbf3f3]you need to be logged in.", player );
else{
Message("[#00de00]Administration Command: [#fbf3f3]Admin "+player.Name+" has got all players to his location.");
for (local i=0; i<GetMaxPlayers(); i++)
{
local p=FindPlayer(i);
if(p)
{
p.Pos = player.Pos;
}
}
}
}

=RK=MarineForce

Function OnGetPlayer
 {
        if ( IsNum( plr ) )
        {
            plr = FindPlayer( plr.tointeger() );
            if ( plr ) return plr;
            else return null;
        }
     else
        {     
            plr = FindPlayer( plr );
            if ( plr ) return plr;
            else return null;
        }
    }
    else return null;
}

No Working >>

=RK=MarineForce

Thanks for Getall Cmd.
but it working without function <3

Mahmoud Tornado

Quote from: =RK=MarineForce on May 12, 2018, 07:10 AMFunction OnGetPlayer
 {
        if ( IsNum( plr ) )
        {
            plr = FindPlayer( plr.tointeger() );
            if ( plr ) return plr;
            else return null;
        }
     else
        {     
            plr = FindPlayer( plr );
            if ( plr ) return plr;
            else return null;
        }
    }
    else return null;
}

No Working >>

WTF?!!
function GetPlayer( plr )

umar4911

Quote from: vitogta on May 12, 2018, 09:26 PMusing NewTimer per each operation in your server keep in mind there is a limit of native timers instances around 128
then what should we do in that situation.
RT Member | Asian City Scripter | CTB Contributor | VKs Contributor | European City Contributor | EAD Scripter

=RK=MarineForce

I m trying to make itThanks For Support I will try hard okay :D

nippon

Quote from: Mahmoud Tornado on May 11, 2018, 07:16 PM
Quote from: =RK=MarineForce on May 11, 2018, 06:23 PMHEY Man i have to fixed this goto cmd

else if ( cmd == "goto" )
{
if ( !text ) MessagePlayer( "[#ff0000]Syntax - /" + cmd + " <Player Nick/ID>", player );
else {
local plr = FindPlayer( text );
if ( !plr ) MessagePlayer( "[#ff0000]Error - Unknown Player..", player );
else if ( plr.ID == player.ID ) MessagePlayer( "[#ff0000]Error - You can't teleport to yourself!", player );
else if ( !plr.IsSpawned ) MessagePlayer( "[#ff0000]Error - The Player hasn't spawned yet..", player );
else {
NewTimer( "goto", 3000, 1, player.ID, plr.ID );
Announce( "Teleporting...", player , 0 );
player.IsFrozen = true;
MessagePlayer( "[#ffbb00]You Will Be Teleported In 3 Seconds To " + plr.Name + ". ", player);
}
}
}

Change this Local plr = GetPlayer(text); to Local plr = FindPlayer ( text ); its work for me when i fixed it
As you don't have GetPlayer Function.
FindPlayer is an normal function.
The both work but you don't have GetPlayer Function.


Whenever i use the cmd, it says wait 3s but i wait too much and doesnt working

umar4911

Quote from: nippon on Jul 02, 2018, 12:44 AM
Quote from: Mahmoud Tornado on May 11, 2018, 07:16 PM
Quote from: =RK=MarineForce on May 11, 2018, 06:23 PMHEY Man i have to fixed this goto cmd

else if ( cmd == "goto" )
{
if ( !text ) MessagePlayer( "[#ff0000]Syntax - /" + cmd + " <Player Nick/ID>", player );
else {
local plr = FindPlayer( text );
if ( !plr ) MessagePlayer( "[#ff0000]Error - Unknown Player..", player );
else if ( plr.ID == player.ID ) MessagePlayer( "[#ff0000]Error - You can't teleport to yourself!", player );
else if ( !plr.IsSpawned ) MessagePlayer( "[#ff0000]Error - The Player hasn't spawned yet..", player );
else {
NewTimer( "goto", 3000, 1, player.ID, plr.ID );
Announce( "Teleporting...", player , 0 );
player.IsFrozen = true;
MessagePlayer( "[#ffbb00]You Will Be Teleported In 3 Seconds To " + plr.Name + ". ", player);
}
}
}

Change this Local plr = GetPlayer(text); to Local plr = FindPlayer ( text ); its work for me when i fixed it
As you don't have GetPlayer Function.
FindPlayer is an normal function.
The both work but you don't have GetPlayer Function.


Whenever i use the cmd, it says wait 3s but i wait too much and doesnt working
Did you change GetPlayer to FindPlayer or you have the GetPlayer function?
RT Member | Asian City Scripter | CTB Contributor | VKs Contributor | European City Contributor | EAD Scripter