If Bool = true ?
#1

Hey, its a simple question but I don't know how to formulate this question on ****** so I ask her


I just maked a bool for my register system. I want to activate/deactivate the registration with it.
how to ask if registerz (bool) = true or false??
:

new bool: registerz;
stock Register(playerid,key[])
Quote:

{
if(registerz) // If registerz = true > The registration is activatet
{
new Spieler[64];
new Sname[MAX_PLAYER_NAME];
GetPlayerName(playerid,Sname,sizeof(Sname));
format(Spieler,sizeof(Spieler),"/Spieler/%s.txt",Sname);
SpielerReset(playerid);
dini_Create(Spieler);
dini_Set(Spieler,"Passwort",key);
dini_IntSet(Spieler,"Level",0);
dini_IntSet(Spieler,"Fraktion",0);
dini_IntSet(Spieler,"Team",0);
dini_IntSet(Spieler,"Deaktiviert",false);
dini_IntSet(Spieler,"Prison",false);
dini_IntSet(Spieler,"Skinauswahl",false);
SendClientMessage(playerid,BLAU,"[Server]: Sucessfully Registered");
SpawnPlayer(playerid);
huso[playerid] = 1;
return 1;
}
return 1;
}

Quote:

public OnPlayerConnect(playerid)
{
if(IsPlayerNPC(playerid)) return 1;
new string[128];// 128 ist die Maximale Lдnge des Textes
new pid;
new ficken[128];
SetPlayerSpecialAction(playerid,SPECIAL_ACTION_CUF FED);
format(string, sizeof(string), "[Server] Welcome %s", GetName(playerid));
SendClientMessage(playerid, -1, string);
format(ficken, sizeof(ficken), "%s has joined the Server", GetName(playerid));
SendClientMessageToAll(0x0005FFFF, ficken);
new Spieler[64];
huso[playerid] = 0;
cuffed[pid] = 0;
cuffed[playerid] = 0;
new Sname[MAX_PLAYER_NAME];
GetPlayerName(playerid,Sname,sizeof(Sname));
format(Spieler,sizeof(Spieler),"/Spieler/%s.txt",Sname);
if(dini_Exists(Spieler))
{
SendClientMessage(playerid,0xFFAA00FF,"[Server]: Welcome back");
ShowPlayerDialog(playerid,LOGIN,DIALOG_STYLE_PASSW ORD,"Login","Your Account was found. Login.","Login","Cancel");
return 1;
}
else
{
if(registerz = true) ((I know that this wouldn't work // Here is the Problem how to ask if registerz (bool) = true or false??
{
SendClientMessage(playerid,0x00B9FFFF,"Welcome to "ClanTag" DEATHMATCH /killme to Respawn!");
ShowPlayerDialog(playerid,REGISTER,DIALOG_STYLE_IN PUT,"Register","Choose a Password to register","Register","Cancel");
return 1;
}
else
{
ShowPlayerDialog(playerid, 38, DIALOG_STYLE_MSGBOX, "Registration", "The Registration was deactivatet by an Administrator", "Close", "");
SetTimerEx("KickTimer", 1000, false, "i", playerid);
}
return 1;

}
}

Reply
#2

PHP код:
if(!registerz//false
if(registerz//true 
or

PHP код:
if(registerz == false//false
if(registerz == true//true 
Reply
#3

ahhh fuck thx -.-


But I get this error: error 017: undefined symbol "registerz"


But new bool:registerz; is already defined in stock register



If I copy it there it says ": local variable "registerz" shadows a variable at a preceding level"
Reply
#4

Yes here:

public OnPlayerConnect(playerid)
{
new bool:registerz;
if(IsPlayerNPC(playerid)) return 1;
new string[128];// 128 ist die Maximale Lдnge des Textes
new pid;
new ficken[128];
SetPlayerSpecialAction(playerid,SPECIAL_ACTION_CUF FE
Reply
#5

You need database where you store if users name is regsitered or not, plain param doesnt contain that kind of information.
Reply
#6

this database is existing ^^ "dini"

Where to place the bool now?
Reply
#7

I suggest you to use english when writing code, then others can also understand what are you writing.
PHP код:
UName(pid){
    new 
s[24];
    
GetPlayerName(pid,s,24);
    return 
s;
}
public 
OnPlayerConnect(playerid){
    new 
pid=playerid,s[50];
    if(
IsPlayerNPC(pid)) return 1;
    
ff(s,"users/%s.ini",UName(pid));
    if(
fexists(s)){
        
SendClientMessage(playerid,0xFFAA00FF,"[Server]: Welcome back");
        
ShowPlayerDialog(playerid,LOGIN,DIALOG_STYLE_PASSWORD,"Login","Your Account was found. Login.","Login","Cancel");
    }else{
        
ShowPlayerDialog(playerid38DIALOG_STYLE_MSGBOX"Registration""The Registration was deactivatet by an Administrator""Close""");
        
SetTimerEx("KickTimer",1000,false,"i",playerid);// its like 1 sec, nobody cant register with this amount of time
    
}
    return 
1;

Reply
#8

new bool:registerz on top of gamemode
Reply
#9

Quote:
Originally Posted by DeStRoY232
Посмотреть сообщение
new bool:registerz on top of gamemode
Thx to everybody! Its working!
Reply
#10

Quote:
Originally Posted by pulsare
Посмотреть сообщение
Thx to everybody! Its working!
It works for one, but if you haven't made it an array, when people connect at the same time it will fail.


You need to realize WHY this occurred, and it happened because when you made the variable under OnPlayerConnect, that was the only place the variable will exist.

This is another reason why you should almost be using a value in the player infos enum to do this.



Seriously though, it may work currently, but when people start connecting, it's going to fail and cause problems.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)