SA-MP Forums Archive
Need a little help with something please. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need a little help with something please. (/showthread.php?tid=286743)



Need a little help with something please. - moadi - 30.09.2011

Hey there ,

I've been trying to script an elevator , everything is working fine till now except one thing :

Code:
//=================ELEUP==========================
	if (strcmp("/eleup", cmdtext, true, 10) == 0){

    	MoveObject(object2,1222.9000244141, -1667, 29.10000038147, 2.00);
    	SetTimer("ele", 8000, 0);
    	
	 }

//====================ELECDOWN==========================
	if (strcmp("/eledown", cmdtext, true, 10) == 0){
	MoveObject(object2,1222.9000244141, -1667, 29.10000038147, 2.00);
	SetTimer("eledown", 4000, 0);
	}

//=================================================
public ele()
{
MoveObject(object2,1213.5999755859, -1668.1999511719, 29.10000038147, 3.00);
return 1;
}
//=================================================
public eledown()
{
MoveObject(object2,1222.3000488281, -1668.0999755859, 12.5, 3.00);
return 1;
}

//I've done this timer thingy because the elevator doesn't go straight up , moves left and right aswell ..
It's all working fine but how can i make it that if the elevator is moving up the player won't be able to use /eledown until the elevator reaches it up.

Thanks in advance .


Re: Need a little help with something please. - Raimis_R - 30.09.2011

pawn Code:
new bool:EleOrder[MAX_PLAYERS];

//=================ELEUP==========================
if (strcmp("/eleup", cmdtext, true, 6) == 0)
{
    MoveObject(object2,1222.9000244141, -1667, 29.10000038147, 2.00);
    SetTimer("ele", 8000, 0);
    return 1;
}

//====================ELECDOWN==========================
if (strcmp("/eledown", cmdtext, true, 8) == 0)
{
    if (EleOrder[playerid])return 0;
   
    MoveObject(object2,1222.9000244141, -1667, 29.10000038147, 2.00);
    SetTimer("eledown", 4000, 0);
    EleOrder[playerid] = true;
    return 1;
}

//=================================================
public ele()
{
    MoveObject(object2,1213.5999755859, -1668.1999511719, 29.10000038147, 3.00);
    return 1;
}
//=================================================
public eledown()
{
    MoveObject(object2,1222.3000488281, -1668.0999755859, 12.5, 3.00);
    EleOrder[playerid] = false;
    return 1;
}



Re: Need a little help with something please. - Jafet_Macario - 30.09.2011

pawn Code:
new bool: elevator; // TOP
//=================ELEUP==========================
    if (strcmp("/eleup", cmdtext, true, 10) == 0){

        MoveObject(object2,1222.9000244141, -1667, 29.10000038147, 2.00);
        SetTimer("ele", 8000, 0);
        elevator = true;
       
     }

//====================ELECDOWN==========================
    if (strcmp("/eledown", cmdtext, true, 10) == 0)
    {
        if(elevator == true) return SendClientMessage(playerid, -1,"The elevator is moving up, you can't use /eledown");
        MoveObject(object2,1222.9000244141, -1667, 29.10000038147, 2.00);
        SetTimer("eledown", 4000, 0);
    }

//=================================================
public ele()
{
    MoveObject(object2,1213.5999755859, -1668.1999511719, 29.10000038147, 3.00);
    elevator = false;
    return 1;
}
//=================================================
public eledown()
{
    MoveObject(object2,1222.3000488281, -1668.0999755859, 12.5, 3.00);
    return 1;
}



Re: Need a little help with something please. - moadi - 30.09.2011

Works , thanks .


Re: Need a little help with something please. - moadi - 30.09.2011

Quote:
Originally Posted by Raimis_R
View Post
pawn Code:
new bool:EleOrder[MAX_PLAYERS];

//=================ELEUP==========================
if (strcmp("/eleup", cmdtext, true, 6) == 0)
{
    MoveObject(object2,1222.9000244141, -1667, 29.10000038147, 2.00);
    SetTimer("ele", 8000, 0);
    return 1;
}

//====================ELECDOWN==========================
if (strcmp("/eledown", cmdtext, true, 8) == 0)
{
    if (EleOrder[playerid])return 0;
   
    MoveObject(object2,1222.9000244141, -1667, 29.10000038147, 2.00);
    SetTimer("eledown", 4000, 0);
    EleOrder[playerid] = true;
    return 1;
}

//=================================================
public ele()
{
    MoveObject(object2,1213.5999755859, -1668.1999511719, 29.10000038147, 3.00);
    return 1;
}
//=================================================
public eledown()
{
    MoveObject(object2,1222.3000488281, -1668.0999755859, 12.5, 3.00);
    EleOrder[playerid] = false;     // the line with the error
    return 1;
}
I actually got this error
Code:
(163) error 017 undefined symbol "playerid"



Re: Need a little help with something please. - Jafet_Macario - 30.09.2011

Try mine.


Re: Need a little help with something please. - moadi - 30.09.2011

Quote:
Originally Posted by Jafet_Macario
View Post
Try mine.
Just did , works perfectly , thanks .