Lock Team
#1

Hello i want to lock team TF141 with password... How to do it? Here is the code:
PHP код:
// Teams
#define TEAM_CIVIL 0
#define TEAM_GROVE 1
#define TEAM_BALLAS 2
#define TEAM_VAGOS 3
#define TEAM_AZTECAS 4
#define TEAM_LSPD 5
#define TEAM_TF141 
PHP код:
public OnPlayerRequestClass(playeridclassid)
{
    
gPlayerClass[playerid] = classid;
    switch (
classid) {
        case 
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19:
            {
                
gTeam[playerid] = TEAM_CIVIL;
                
GameTextForPlayer(playerid"~y~~h~~h~CIVILIAN"10006);
            }
        case 
20,21,22:
            {
                
gTeam[playerid] = TEAM_GROVE;
                
GameTextForPlayer(playerid"~g~Grove Street Families"10006);
                
ApplyAnimation(playerid,"PED","strip_G",4.1,1,1,1,1,1);
            }
        case 
23,24,25:
            {
                
gTeam[playerid] = TEAM_BALLAS;
                
GameTextForPlayer(playerid"~p~Front Yard Ballas"10006);
                
ApplyAnimation(playerid,"PED","strip_G",4.1,1,1,1,1,1);
            }
            case 
26,27,28:
            {
                
gTeam[playerid] = TEAM_VAGOS;
                
GameTextForPlayer(playerid"~y~Los Santos Vagos"10006);
                
ApplyAnimation(playerid,"PED","strip_G",4.1,1,1,1,1,1);
            }
            case 
29,30,31:
            {
                
gTeam[playerid] = TEAM_AZTECAS;
                
GameTextForPlayer(playerid"~b~~h~~h~Vario Los Azteca"10006);
            }
            case 
32,33,34,35:
            {
                
gTeam[playerid] = TEAM_LSPD;
                
GameTextForPlayer(playerid"~y~~h~~h~LOS SANTOS POLICE DEPARTAMENT"10006);
            }
    }
    
SetPlayerPos(playerid2524.2695,-1696.2926,18.2204);
    
SetPlayerFacingAngleplayerid2.3616 );
    
SetPlayerCameraPos(playerid2523.7749,-1692.6855,18.9011);
    
SetPlayerCameraLookAt(playerid2524.2695,-1696.2926,18.2204);
    return 
1;

If you need player class tell me
Reply
#2

You need to add the class like all others, however in OnPlayerRequestSpawn do the following:

Код:
public OnPlayerRequestSpawn(playerid)
{
    if(gTeam[playerid] == TEAM_TF141)
    {
        ShowPlayerDialog(playerid, DIALOG_CLASS_TF141, DIALOG_STYLE_PASSWORD, "Password protected Class", "Please enter a Password to choose this Class:", "Spawn", "Back"); // password dialog
        return 0; // Prevents Spawn
    }
    return 1;
}
Then, in OnDialogResponse:

Код:
if(dialogid == DIALOG_CLASS_TF141) // I name dialog ID defines like this, replace with your ID from ShowPlayerDialog!
{
    if(response)
    {
        if(strcmp(inputtext, "YourPassword", false) == 0 && strlen(inputtext) != 0)
        {
            SpawnPlayer(playerid); // Entered correct password, may spawn
        }
        else
        {
            // Wrong password, tell the player
        }
    }
    return 1;
}
This should work fine, even on respawning. If the player changes the class to some other and then back, he has to re-enter the password though.

Make sure you also set gTeam to TEAM_TF141 like (for example) TEAM_AZTECAS inside OnPlayerRequestClass. Also the define TEAM_TF141 needs a value (6 I guess).
Reply
#3

PHP код:
C:\Users\Борисов\Desktop\BG RP Server\gamemodes\BG1.2.pwn(1228) : error 017undefined symbol "DIALOG_CLASS_TF141"
C:\Users\Борисов\Desktop\BG RP Server\gamemodes\BG1.2.pwn(1429) : error 017undefined symbol "DIALOG_CLASS_TF141"
C:\Users\Борисов\Desktop\BG RP Server\gamemodes\BG1.2.pwn(1445) : warning 209: function "OnDialogResponse" should return a value
Pawn compiler 3.2.3664              Copyright 
(c1997-2006ITB CompuPhase


2 Errors

Reply
#4

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	return 0; // you forgot this :)
}
If you fix this, other errors get fixed too!

Remember the format
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_CLASS_TF141) // I name dialog ID defines like this, replace with your ID from    ShowPlayerDialog!
    {
        if(response)
        {
            if(strcmp(inputtext, "YourPassword", false) == 0 && strlen(inputtext) != 0)
            {
                SpawnPlayer(playerid); // Entered correct password, may spawn
            }  
            else
            {
                // Wrong password, tell the player
            }
        }
    }
    if(statement)
    {
            // (Arguements)
    }
    return 0;
}
[NaS's command]
Reply
#5

PHP код:
C:\Users\Борисов\Desktop\BG RP Server\gamemodes\BG1.2.pwn(1228) : error 017undefined symbol "DIALOG_CLASS_TF141"
C:\Users\Борисов\Desktop\BG RP Server\gamemodes\BG1.2.pwn(1430) : error 017undefined symbol "DIALOG_CLASS_TF141"
C:\Users\Борисов\Desktop\BG RP Server\gamemodes\BG1.2.pwn(1447) : error 029invalid expressionassumed zero
C
:\Users\Борисов\Desktop\BG RP Server\gamemodes\BG1.2.pwn(1447) : error 004: function "OnPlayerClickPlayer" is not implemented
C
:\Users\Борисов\Desktop\BG RP Server\gamemodes\BG1.2.pwn(1451) : error 030compound statement not closed at the end of file (started at line 1430)
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
5 Errors

Reply
#6

Post your OnPlayerDialogResponse so I can check
Reply
#7

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
if(
dialogid == DIALOG_CLASS_TF141// I name dialog ID defines like this, replace with your ID from ShowPlayerDialog!
{
    if(
response)
    {
        if(
strcmp(inputtext"1820141"false) == && strlen(inputtext) != 0)
        {
            
SpawnPlayer(playerid); // Entered correct password, may spawn
        
}
        else
        {
            
SendClientMessage(playeridCOLOR_RED"Грешна парола!");
        }
        return 
1;
    }
    return 
0;

Reply
#8

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_CLASS_TF141) // I name dialog ID defines like this, replace with your ID from ShowPlayerDialog!
    {
        if(response)
        {
            if(strcmp(inputtext, "1820141", false) == 0 && strlen(inputtext) != 0)
            {
                SpawnPlayer(playerid); // Entered correct password, may spawn
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "Грешна парола!");
            }  
            return 1;
        }
    } // Forgot this? :D
    return 0;
}
Reply
#9


PHP код:
C:\Users\Борисов\Desktop\BG RP Server\gamemodes\BG1.2.pwn(1228) : error 017undefined symbol "DIALOG_CLASS_TF141"
C:\Users\Борисов\Desktop\BG RP Server\gamemodes\BG1.2.pwn(1430) : error 017undefined symbol "DIALOG_CLASS_TF141"
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase


2 Errors

Reply
#10

Put this on top near the other #define (s)
Код:
#define DIALOG_CLASS_TF141 1025 // you can use any number other than 1025
Solved?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)