Hallo.
Ich möchte es gerne so in mein Script einbauen wie folgt:
Man connected auf den Server und muss einen Beta Key eingeben, den ein Admin erstellen muss.
Wenn man einen richtigen Beta Key eingegeben hat, wird der Login/Register Dialog angezeigt.
Falls nicht, wird man gekickt.
Falls man einen richtigen eingegeben hat, soll ein Wert in die Datenbanktabelle "beta" eingetragen werden.
Wenn er auf 0 ist -> Beta Key eingeben, falls er auf 1 ist -> Login
Meine Frage nun, wie setze ich das um?
public OnUserCheck(playerid)
{
new num_rows,num_fields;
cache_get_data(num_rows,num_fields,dbhandle);
if(num_rows==0)
{
//Registrierung
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Registrierung","Gib bitte dein gewünschtes Passwort an:","Okay","Abbrechen");
}
else
{
//Login
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Gibt bitte dein Passwort ein:","Okay","Abbrechen");
}
return 1;
}
public OnPlayerConnect(playerid)
{
//Spieler Connect
new TextString[128];
SpielerClearMessage(playerid);
SendClientMessage(playerid,Gold,"Herzlich Willkommen auf dem: Grand Theft Auto: Nemonicon Server.");
SendClientMessage(playerid,Gold,"Du kannst dich nun Anmelden / Registrieren!");
format(TextString,sizeof(TextString),"[Connect] %s hat den Server betreten.",SpielerName(playerid));
SendClientMessageToAll(COLOR_ORANGE,TextString);
//Spieler Mapicons
SetPlayerMapIcon(playerid,0,24.7629,1167.7544,19.5175,38,0); //Neuling Spawn
//Login/Register
new name[MAX_PLAYER_NAME],query[128];
GetPlayerName(playerid,name,sizeof(name));
format(query,sizeof(query),"SELECT id FROM user WHERE username='%s'",name);
mysql_function_query(dbhandle,query,true,"OnUserCheck","i",playerid);
//textdraw anzeigen
TextDrawShowForPlayer(playerid, uhrzeitLabel);
//Spielerfarbe setzen
SetPlayerColor(playerid, COLOR_WHITE);
//Textdraw erstellen Tank
tankLabel[playerid] = CreatePlayerTextDraw(playerid, 480.000000, 322.000000, "Tank: 100%");
PlayerTextDrawBackgroundColor(playerid, tankLabel[playerid], 255);
PlayerTextDrawFont(playerid, tankLabel[playerid], 1);
PlayerTextDrawLetterSize(playerid, tankLabel[playerid], 0.500000, 1.600000);
PlayerTextDrawColor(playerid, tankLabel[playerid], -1);
PlayerTextDrawSetOutline(playerid, tankLabel[playerid], 0);
PlayerTextDrawSetProportional(playerid, tankLabel[playerid], 1);
PlayerTextDrawSetShadow(playerid, tankLabel[playerid], 1);
PlayerTextDrawUseBox(playerid, tankLabel[playerid], 1);
PlayerTextDrawBoxColor(playerid, tankLabel[playerid], 0x00000055);
//TextDrawBoxColor(Tachohintergrund, 0x00000055);
PlayerTextDrawTextSize(playerid, tankLabel[playerid], 582.000000, 130.000000);
PlayerTextDrawHide(playerid, tankLabel[playerid]);
//Haltestellen Textdraw
Textdraw0 = CreatePlayerTextDraw(playerid,246.000000, 171.000000, "Haltestelle %d/10");
PlayerTextDrawBackgroundColor(playerid,Textdraw0, 255);
PlayerTextDrawFont(playerid,Textdraw0, 2);
PlayerTextDrawLetterSize(playerid,Textdraw0, 0.390000, 1.400000);
PlayerTextDrawColor(playerid,Textdraw0, -1);
PlayerTextDrawSetOutline(playerid,Textdraw0, 1);
PlayerTextDrawSetProportional(playerid,Textdraw0, 1);
PlayerTextDrawSetSelectable(playerid,Textdraw0, 0);
//Stadthallen Straßen Texture Remove
RemoveBuildingForPlayer(playerid, 4163, 1469.3359, -1732.2891, 12.4609, 0.25);
RemoveBuildingForPlayer(playerid, 4164, 1469.3359, -1732.2891, 12.4609, 0.25);
return 1;
}
Spieler speichern
savePlayer(playerid)
{
if(sInfo[playerid][eingeloggt]==0)return 1;
//Speichern Level,geld
new query[256];
format(query,sizeof(query),"UPDATE user SET level = '%i', money = '%i', alevel = '%i', fraktion = '%i', rang = '%i', spawnchange = '%i', perso = '%i', job = '%i', busskill = '%i', busskilllevel = '%i', muellskill = '%i', muellskilllevel = '%i', pilotskill = '%i', pilotskilllevel = '%i' WHERE id='%i'",
sInfo[playerid][level],
GetPlayerMoney(playerid),
sInfo[playerid][alevel],
sInfo[playerid][fraktion],
sInfo[playerid][rang],
sInfo[playerid][spawnchange],
sInfo[playerid][perso],
sInfo[playerid][job],
sInfo[playerid][busskill],
sInfo[playerid][busskilllevel],
sInfo[playerid][muellskill],
sInfo[playerid][muellskilllevel],
sInfo[playerid][pilotskill],
sInfo[playerid][pilotskilllevel],
sInfo[playerid][db_id]);
mysql_function_query(dbhandle,query,false,"","");
return 1;
}
Spieler laden:
public OnPasswordResponse(playerid)
{
new num_fields,num_rows;
cache_get_data(num_rows,num_fields,dbhandle);
if(num_rows==1)
{
//Passwort richtig //Spieler laden
sInfo[playerid][eingeloggt] = 1;
sInfo[playerid][level] = cache_get_field_content_int(0,"level",dbhandle);
SetPlayerScore(playerid,sInfo[playerid][level]);
sInfo[playerid][db_id] = cache_get_field_content_int(0,"id",dbhandle);
SetPlayerMoney(playerid,cache_get_field_content_int(0,"money",dbhandle));
sInfo[playerid][alevel] = cache_get_field_content_int(0,"alevel",dbhandle);
sInfo[playerid][fraktion] = cache_get_field_content_int(0,"fraktion",dbhandle);
sInfo[playerid][rang] = cache_get_field_content_int(0,"rang",dbhandle);
sInfo[playerid][spawnchange] = cache_get_field_content_int(0,"spawnchange",dbhandle);
sInfo[playerid][perso] = cache_get_field_content_int(0,"perso",dbhandle);
sInfo[playerid][job] = cache_get_field_content_int(0,"job",dbhandle);
sInfo[playerid][busskill] = cache_get_field_content_int(0,"busskill",dbhandle);
sInfo[playerid][busskilllevel] = cache_get_field_content_int(0,"busskilllevel",dbhandle);
sInfo[playerid][muellskill] = cache_get_field_content_int(0,"muellskill",dbhandle);
sInfo[playerid][muellskilllevel] = cache_get_field_content_int(0,"muellskilllevel",dbhandle);
sInfo[playerid][muellskilllevel] = cache_get_field_content_int(0,"pilotskill",dbhandle);
sInfo[playerid][muellskilllevel] = cache_get_field_content_int(0,"pilotskilllevel",dbhandle);
loadSpielerAutos(playerid);
}
else
{
//Passwort falsch
SendClientMessage(playerid,COLOR_RED,"Das eingegebene Passwort ist falsch.");
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Gibt bitte dein Passwort ein:","Okay","Abbrechen");
}
return 1;
}