Why No work?

Started by kennedyarz, Apr 09, 2017, 08:47 PM

Previous topic - Next topic

kennedyarz

function onScriptLoad()
{
        canenter <- array(GetMaxPlayers(),false)
canenter2 <- array(GetMaxPlayers(),false)
ENTER <- BindKey(true, 0x0D, 0, 0);
        CreateCheckpoint();
}

function CreateCheckpoint()
{
CreateCheckpoint(null, 1, true, Vector(18.6172,-1296.44,10.4633), RGB(0, 0, 200), 1);
CreateCheckpoint(null, 1, true, Vector(-1483,476.697,3497.33), RGB(0, 0, 200), 1);
CreateCheckpoint(null, 1, true, Vector(24.6771,-1360.43,10.4633), RGB(0, 0, 200), 1);
CreateCheckpoint(null, 1, true, Vector(-1483,476.697,3497.33), RGB(0, 0, 200), 1);
}

function onCheckpointEntered(player, CheckPoint)
{
canenter[ player.ID ]=true;
if( canenter[ player.ID ] && canenter2[player.ID] == false ) return 0;
else if ( canenter[player.ID] && canenter2[ player.ID ] == true )
{
switch( CheckPoint.ID )
{
//================================= Teleport 2 ==============================================//
case 0:
player.Pos = Vector(-1485.6,539.804,3497.3);
break;
case 1:
player.Pos = Vector(-368.43,-419.602,10.7295);
break;
}
}
return0;
}

function onCheckpointExited( player, checkpoint )
{
canenter[player.ID]=false;
canenter2[player.ID]=false;
}

function onKeyUp( player, key )
{
if ( key == ENTER )
{
if ( canenter[player.ID] == true )
{
       canenter2[player.ID] = true;
       Announce( "~s~Point: ~y~Yes", player, 1 );
}
else Announce( "~s~Point: ~y~No", player, 1 );
}
}

It is a function where if the player enters the checkpoint and presses a key key, he will be teleported, when he leaves the checkpoint he can not be teleported, it is only for when he is in the point.

KAKAN

change the else if in onCheckpoint Entered to if.
Also, try debugging the program and tell us where it exactly happens
oh no

kennedyarz

Quote from: KAKAN on Apr 10, 2017, 05:00 AMchange the else if in onCheckpoint Entered to if.
Also, try debugging the program and tell us where it exactly happens

That is not the problem @KAKAN, when you enter the checkpoint canenter is placed "true" for that player and only need the player to press "ENTER" so that canenter2 is also set to "true" and then gives you permission to do the function in The checkpoint. But it does not.

KAKAN

local abc = true;
if( abc ) print("YES!");
else if( abc ) print("yes!");
That's what you're doing.
The first one will be done, but not the second. Try running that code and this code:-
local abc = true;
if( abc ) print("YES!");
if( abc ) print("yes!");
I don't have patience to check your whole code. So, try that and as I said, add debug checks.
oh no

kennedyarz

Quote from: KAKAN on Apr 10, 2017, 01:12 PMlocal abc = true;
if( abc ) print("YES!");
else if( abc ) print("yes!");
That's what you're doing.
The first one will be done, but not the second. Try running that code and this code:-
local abc = true;
if( abc ) print("YES!");
if( abc ) print("yes!");
I don't have patience to check your whole code. So, try that and as I said, add debug checks.

Thanks, but use a less reliable method :(


Shadow

Quote from: kennedyarz on Apr 09, 2017, 08:47 PMfunction onScriptLoad()
{
        canenter <- array(GetMaxPlayers(),false)
canenter2 <- array(GetMaxPlayers(),false)
ENTER <- BindKey(true, 0x0D, 0, 0);
        CreateCheckpoint();
}

function CreateCheckpoint()
{
CreateCheckpoint(null, 1, true, Vector(18.6172,-1296.44,10.4633), RGB(0, 0, 200), 1);
CreateCheckpoint(null, 1, true, Vector(-1483,476.697,3497.33), RGB(0, 0, 200), 1);
CreateCheckpoint(null, 1, true, Vector(24.6771,-1360.43,10.4633), RGB(0, 0, 200), 1);
CreateCheckpoint(null, 1, true, Vector(-1483,476.697,3497.33), RGB(0, 0, 200), 1);
}

Probably not going to fix your issue but you're defining a function with CreateCheckpoint which possibly overloads the plugin function CreateCheckpoint, are you sure that is the intended behaviour?
QuotePS:is trash is ur home language??

Saiyan Attack

#6
This Will Work When You Press Enter ...
function onScriptLoad()
{
canenter <- array(GetMaxPlayers(),false);
teleport <- array(GetMaxPlayers(),0);
ENTER <- BindKey(true, 0x0D, 0, 0);
MakePoint();
}

function MakePoint()
{
CreateCheckpoint(null, 1, true, Vector(18.6172,-1296.44,10.4633), ARGB(255, 0, 0,200), 1);
CreateCheckpoint(null, 1, true, Vector(-1483,476.697,3497.33), ARGB(255, 0, 0,200), 1);
CreateCheckpoint(null, 1, true, Vector(24.6771,-1360.43,10.4633), ARGB(255, 0, 0,200), 1);
CreateCheckpoint(null, 1, true, Vector(-1483,476.697,3497.33), ARGB(255, 0, 0,200), 1);
}

function onCheckpointEntered(player, checkpoint)
{
if (canenter[player.ID]==false) {
canenter[player.ID]=true;
teleport[player.ID]=checkpoint.ID;
}
}

function onKeyUp( player, key )
{
if (key == ENTER) {
if (canenter[player.ID] == true) {
switch(teleport[player.ID]) {
case 0: player.Pos = Vector(-1485.6,539.804,3497.3); break;
case 1: player.Pos = Vector(-368.43,-419.602,10.7295); break;
default: break;
}
Announce("~s~Point: ~y~Yes", player, 1);
canenter[player.ID]=false;
teleport[player.ID]=0;
}
else Announce("~s~Point: ~y~No",player,1);
}
}

And This Will Work When You Press Enter And Leave The Checkpoint ...
function onScriptLoad()
{
canenter <- array(GetMaxPlayers(),false)
canenter2 <- array(GetMaxPlayers(),false)
ENTER <- BindKey(true, 0x0D, 0, 0);
MakePoint();
}

function MakePoint()
{
CreateCheckpoint(null, 1, true, Vector(18.6172,-1296.44,10.4633), ARGB(255, 0, 0,200), 1);
CreateCheckpoint(null, 1, true, Vector(-1483,476.697,3497.33), ARGB(255, 0, 0,200), 1);
CreateCheckpoint(null, 1, true, Vector(24.6771,-1360.43,10.4633), ARGB(255, 0, 0,200), 1);
CreateCheckpoint(null, 1, true, Vector(-1483,476.697,3497.33), ARGB(255, 0, 0,200), 1);
}

function onCheckpointEntered(player, CheckPoint)
{
if(canenter[player.ID]==false) canenter[ player.ID ]=true;
}

function onCheckpointExited(player, checkpoint)
{
if((canenter[player.ID]==true) && (canenter2[ player.ID ] == true)) {
switch(CheckPoint.ID) {
case 0: player.Pos = Vector(-1485.6,539.804,3497.3); break;
case 1: player.Pos = Vector(-368.43,-419.602,10.7295); break;
}
canenter[player.ID]=false;
canenter2[player.ID]=false;
}
}

function onKeyUp( player, key )
{
if (key == ENTER) {
if (canenter[player.ID] == true) {
canenter2[player.ID] = true;
Announce( "~s~Point: ~y~Yes", player, 1 );
}
else Announce( "~s~Point: ~y~No", player, 1 );
}
}

kennedyarz

#7
Quote from: Saiyan Attack on Apr 10, 2017, 02:49 PMThis Will Work When You Press Enter ...
function onScriptLoad()
{
canenter <- array(GetMaxPlayers(),false);
teleport <- array(GetMaxPlayers(),0);
ENTER <- BindKey(true, 0x0D, 0, 0);
MakePoint();
}

function MakePoint()
{
CreateCheckpoint(null, 1, true, Vector(18.6172,-1296.44,10.4633), RGB(0, 0, 200,255), 1);
CreateCheckpoint(null, 1, true, Vector(-1483,476.697,3497.33), RGB(0, 0, 200,255), 1);
CreateCheckpoint(null, 1, true, Vector(24.6771,-1360.43,10.4633), RGB(0, 0, 200,255), 1);
CreateCheckpoint(null, 1, true, Vector(-1483,476.697,3497.33), RGB(0, 0, 200,255), 1);
}

function onCheckpointEntered(player, checkpoint)
{
if (canenter[player.ID]==false) {
canenter[player.ID]=true;
teleport[player.ID]=checkpoint.ID;
}
}

function onKeyUp( player, key )
{
if (key == ENTER) {
if (canenter[player.ID] == true) {
switch(teleport[player.ID]) {
case 0: player.Pos = Vector(-1485.6,539.804,3497.3); break;
case 1: player.Pos = Vector(-368.43,-419.602,10.7295); break;
default: break;
}
Announce("~s~Point: ~y~Yes", player, 1);
canenter[player.ID]=false;
teleport[player.ID]=0;
}
else Announce("~s~Point: ~y~No",player,1);
}
}

And This Will Work When You Press Enter And Leave The Checkpoint ...
function onScriptLoad()
{
canenter <- array(GetMaxPlayers(),false)
canenter2 <- array(GetMaxPlayers(),false)
ENTER <- BindKey(true, 0x0D, 0, 0);
MakePoint();
}

function MakePoint()
{
CreateCheckpoint(null, 1, true, Vector(18.6172,-1296.44,10.4633), RGB(0, 0, 200,255), 1);
CreateCheckpoint(null, 1, true, Vector(-1483,476.697,3497.33), RGB(0, 0, 200,255), 1);
CreateCheckpoint(null, 1, true, Vector(24.6771,-1360.43,10.4633), RGB(0, 0, 200,255), 1);
CreateCheckpoint(null, 1, true, Vector(-1483,476.697,3497.33), RGB(0, 0, 200,255), 1);
}

function onCheckpointEntered(player, CheckPoint)
{
if(canenter[player.ID]==false) canenter[ player.ID ]=true;
}

function onCheckpointExited(player, checkpoint)
{
if((canenter[player.ID]==true) && (canenter2[ player.ID ] == true)) {
switch(CheckPoint.ID) {
case 0: player.Pos = Vector(-1485.6,539.804,3497.3); break;
case 1: player.Pos = Vector(-368.43,-419.602,10.7295); break;
}
canenter[player.ID]=false;
canenter2[player.ID]=false;
}
}

function onKeyUp( player, key )
{
if (key == ENTER) {
if (canenter[player.ID] == true) {
canenter2[player.ID] = true;
Announce( "~s~Point: ~y~Yes", player, 1 );
}
else Announce( "~s~Point: ~y~No", player, 1 );
}
}

Thanks, but it's another type of work I'm trying to do
Quote from: Shadow on Apr 10, 2017, 02:28 PM
Quote from: kennedyarz on Apr 09, 2017, 08:47 PMfunction onScriptLoad()
{
        canenter <- array(GetMaxPlayers(),false)
canenter2 <- array(GetMaxPlayers(),false)
ENTER <- BindKey(true, 0x0D, 0, 0);
        CreateCheckpoint();
}

function CreateCheckpoint()
{
CreateCheckpoint(null, 1, true, Vector(18.6172,-1296.44,10.4633), RGB(0, 0, 200), 1);
CreateCheckpoint(null, 1, true, Vector(-1483,476.697,3497.33), RGB(0, 0, 200), 1);
CreateCheckpoint(null, 1, true, Vector(24.6771,-1360.43,10.4633), RGB(0, 0, 200), 1);
CreateCheckpoint(null, 1, true, Vector(-1483,476.697,3497.33), RGB(0, 0, 200), 1);
}

Probably not going to fix your issue but you're defining a function with CreateCheckpoint which possibly overloads the plugin function CreateCheckpoint, are you sure that is the intended behaviour?

I see everything fine, everything works perfect but does not teleport, and the Keys respond well


I am using 383 case in checkPoint. is Much for Modify now