Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Includes
- #include <a_samp>
- #include <sscanf2>
- #include <a_mysql>
- #include <zcmd>
- //enums
- enum playerInfo{
- peingeloggt,
- plevel,
- pid,
- padmin
- }
- //Globale Variablen
- new dbhandle;
- new sInfo[MAX_PLAYERS][playerInfo];
- //Farben
- #define COLOR_RED 0xFF0000FF
- #define COLOR_GREY 0xBEBEBEFF
- #define COLOR_YELLOW 0xF5FF00FF
- //Dialoge
- #define DIALOG_TELEPORT 1
- #define DIALOG_REGISTER 2
- #define DIALOG_LOGIN 3
- //MySQL
- #define db_host ""
- #define db_user ""
- #define db_pass ""
- #define db_db ""
- //Textdraw´s
- new PlayerText:t_auswahl1;
- new PlayerText:t_auswahl2;
- new PlayerText:t_auswahl3;
- new PlayerText:t_auswahl4;
- new PlayerText:t_auswahl5;
- //Forwards
- forward OnUserCheck(playerid);
- forward OnPasswordResponse(playerid);
- main()
- {
- }
- public OnGameModeInit()
- {
- SetGameModeText("Cops and Robbers");
- AddPlayerClass(0,199.0846,-150.0331,1.5781,359.1443,0,0,0,0,0,0);
- DisableInteriorEnterExits();
- ManualVehicleEngineAndLights();
- //MySQL
- dbhandle = mysql_connect(db_host,db_user,db_db,db_pass);
- return 1;
- }
- public OnGameModeExit()
- {
- mysql_close(dbhandle);
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid,199.0846,-150.0331,1.5781);
- SetPlayerCameraPos(playerid, 199.2307,-143.8328,1.5781);
- SetPlayerCameraLookAt(playerid, 199.0846,-150.0331,1.5781);
- SetPlayerFacingAngle(playerid,359.1443);
- return 1;
- }
- 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)
- {
- //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);
- return 1;
- }
- savePlayer(playerid)
- {
- if(sInfo[playerid][peingeloggt]==0)return 1;
- //Speichern level,money
- new query[128];
- format(query,sizeof(query),"UPDATE user SET level='%i',money='%i',adminlevel='%i' WHERE id='%i'",sInfo[playerid][plevel],GetPlayerMoney(playerid),sInfo[playerid][padmin],sInfo[playerid][pid]);
- mysql_function_query(dbhandle,query,false,"","");
- return 1;
- }
- resetPlayer(playerid)
- {
- for(new i=0;i<sizeof(sInfo[]); i++)
- {
- sInfo[playerid][playerInfo:i] = 0;
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- savePlayer(playerid);
- resetPlayer(playerid);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- return 0;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- return 1;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(newkeys & KEY_ANALOG_DOWN)
- {
- new t_engine,t_lights,t_alarm,t_doors,t_boonet,t_boot,t_object;
- new vID = GetPlayerVehicleID(playerid);
- if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid,COLOR_GREY," Du bist nicht der Fahrer dest Fahrzeuges!");
- GetVehicleParamsEx(vID,t_engine,t_lights,t_alarm,t_doors,t_boonet,t_boot,t_object);
- if(t_engine == 1)
- {
- t_engine = 0;
- SendClientMessage(playerid,COLOR_YELLOW,"Motor ausgeschaltet!");
- }else{
- t_engine = 1;
- SendClientMessage(playerid,COLOR_YELLOW,"Motor angeschaltet!");
- }
- SetVehicleParamsEx(vID,t_engine,t_lights,t_alarm,t_doors,t_boonet,t_boot,t_object);
- return 1;
- }
- return 1;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return 1;
- }
- SetPlayerMoney(playerid,money)
- {
- ResetPlayerMoney(playerid);
- GivePlayerMoney(playerid,money);
- return 1;
- }
- public OnPasswordResponse(playerid)
- {
- new num_fields,num_rows;
- cache_get_data(num_rows,num_fields,dbhandle);
- if(num_rows==1)
- {
- //Passwort richtig
- sInfo[playerid][peingeloggt] = 1;
- sInfo[playerid][plevel] = cache_get_field_content_int(0,"level",dbhandle);
- sInfo[playerid][padmin] = cache_get_field_content_int(0,"adminlevel",dbhandle);
- SetPlayerScore(playerid,sInfo[playerid][plevel]);
- sInfo[playerid][pid] = cache_get_field_content_int(0,"id",dbhandle);
- SetPlayerMoney(playerid,cache_get_field_content_int(0,"money",dbhandle));
- }
- 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;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid==DIALOG_LOGIN)
- {
- if(response)
- {
- new name[MAX_PLAYER_NAME],query[128],passwort[35];
- GetPlayerName(playerid,name,sizeof(name));
- if(strlen(inputtext)>0)
- {
- mysql_escape_string(inputtext,passwort,dbhandle);
- format(query,sizeof(query),"SELECT * FROM user WHERE username='%s' AND password='%s'",name,passwort);
- mysql_function_query(dbhandle,query,true,"OnPasswordResponse","i",playerid);
- }
- else
- {
- //Keine Eingabe
- SendClientMessage(playerid,COLOR_RED,"Gibt bitte dein Passwort ein.");
- ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Gibt bitte dein Passwort ein:","Okay","Abbrechen");
- }
- }
- else
- {
- Kick(playerid);
- }
- return 1;
- }
- if(dialogid==DIALOG_REGISTER)
- {
- if(response)
- {
- new name[MAX_PLAYER_NAME],query[128],passwort[35];
- GetPlayerName(playerid,name,sizeof(name));
- if(strlen(inputtext)>3)
- {
- //Registrierungsfunktion
- mysql_escape_string(inputtext,passwort,dbhandle);
- format(query,sizeof(query),"INSERT INTO user (username,password) VALUES ('%s','%s') ",name,passwort);
- mysql_function_query(dbhandle,query,false,"","");
- t_auswahl1 = CreatePlayerTextDraw(playerid,178.000000, 107.000000, "_");
- PlayerTextDrawBackgroundColor(playerid,t_auswahl1, 255);
- PlayerTextDrawFont(playerid,t_auswahl1, 1);
- PlayerTextDrawLetterSize(playerid,t_auswahl1, 0.100000, 20.699987);
- PlayerTextDrawColor(playerid,t_auswahl1, -1);
- PlayerTextDrawSetOutline(playerid,t_auswahl1, 0);
- PlayerTextDrawSetProportional(playerid,t_auswahl1, 1);
- PlayerTextDrawSetShadow(playerid,t_auswahl1, 1);
- PlayerTextDrawUseBox(playerid,t_auswahl1, 1);
- PlayerTextDrawBoxColor(playerid,t_auswahl1, 85);
- PlayerTextDrawTextSize(playerid,t_auswahl1, 451.000000, 1.000000);
- PlayerTextDrawSetSelectable(playerid,t_auswahl1, 0);
- t_auswahl2 = CreatePlayerTextDraw(playerid,187.000000, 125.000000, "Kriminelle");
- PlayerTextDrawBackgroundColor(playerid,t_auswahl2, 255);
- PlayerTextDrawFont(playerid,t_auswahl2, 1);
- PlayerTextDrawLetterSize(playerid,t_auswahl2, 0.620000, 1.200000);
- PlayerTextDrawColor(playerid,t_auswahl2, -1);
- PlayerTextDrawSetOutline(playerid,t_auswahl2, 0);
- PlayerTextDrawSetProportional(playerid,t_auswahl2, 1);
- PlayerTextDrawSetShadow(playerid,t_auswahl2, 1);
- PlayerTextDrawSetSelectable(playerid,t_auswahl2, 1);
- SelectTextDraw(playerid, 0xFF4040AA);
- t_auswahl3 = CreatePlayerTextDraw(playerid,363.000000, 125.000000, "Polizei");
- PlayerTextDrawBackgroundColor(playerid,t_auswahl3, 255);
- PlayerTextDrawFont(playerid,t_auswahl3, 1);
- PlayerTextDrawLetterSize(playerid,t_auswahl3, 0.620000, 1.200000);
- PlayerTextDrawColor(playerid,t_auswahl3, -1);
- PlayerTextDrawSetOutline(playerid,t_auswahl3, 0);
- PlayerTextDrawSetProportional(playerid,t_auswahl3, 1);
- PlayerTextDrawSetShadow(playerid,t_auswahl3, 1);
- PlayerTextDrawSetSelectable(playerid,t_auswahl3, 1);
- SelectTextDraw(playerid, 0xFFFA00FF);
- t_auswahl4 = CreatePlayerTextDraw(playerid,204.000000, 151.000000, "_");
- PlayerTextDrawBackgroundColor(playerid,t_auswahl4, 255);
- PlayerTextDrawFont(playerid,t_auswahl4, 1);
- PlayerTextDrawLetterSize(playerid,t_auswahl4, 0.500000, 10.000000);
- PlayerTextDrawColor(playerid,t_auswahl4, -1);
- PlayerTextDrawSetOutline(playerid,t_auswahl4, 0);
- PlayerTextDrawSetProportional(playerid,t_auswahl4, 1);
- PlayerTextDrawSetShadow(playerid,t_auswahl4, 1);
- PlayerTextDrawUseBox(playerid,t_auswahl4, 1);
- PlayerTextDrawBoxColor(playerid,t_auswahl4, 90);
- PlayerTextDrawTextSize(playerid,t_auswahl4, 259.000000, 0.000000);
- PlayerTextDrawSetSelectable(playerid,t_auswahl4, 0);
- PlayerTextDrawSetPreviewModel(playerid, t_auswahl4, 107);
- t_auswahl5 = CreatePlayerTextDraw(playerid,427.000000, 151.000000, "_");
- PlayerTextDrawBackgroundColor(playerid,t_auswahl5, 255);
- PlayerTextDrawFont(playerid,t_auswahl5, 1);
- PlayerTextDrawLetterSize(playerid,t_auswahl5, 2.010000, 10.000000);
- PlayerTextDrawColor(playerid,t_auswahl5, -1);
- PlayerTextDrawSetOutline(playerid,t_auswahl5, 0);
- PlayerTextDrawSetProportional(playerid,t_auswahl5, 1);
- PlayerTextDrawSetShadow(playerid,t_auswahl5, 1);
- PlayerTextDrawUseBox(playerid,t_auswahl5, 1);
- PlayerTextDrawBoxColor(playerid,t_auswahl5, 90);
- PlayerTextDrawTextSize(playerid,t_auswahl5, 363.000000, 0.000000);
- PlayerTextDrawSetSelectable(playerid,t_auswahl5, 0);
- PlayerTextDrawSetPreviewModel(playerid, t_auswahl5, 283);
- PlayerTextDrawShow(playerid,t_auswahl1);
- PlayerTextDrawShow(playerid,t_auswahl2);
- PlayerTextDrawShow(playerid,t_auswahl3);
- PlayerTextDrawShow(playerid,t_auswahl4);
- PlayerTextDrawShow(playerid,t_auswahl5);
- }
- else
- {
- //Kleiner als 4 Zeichen
- SendClientMessage(playerid,COLOR_RED,"Dein Passwort muss mindestens 4 Zeichen lang sein.");
- ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Registrierung","Gib bitte dein gewünschtes Passwort an:","Okay","Abbrechen");
- }
- }
- else
- {
- Kick(playerid);
- }
- return 1;
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- stock isAnAdmin(playerid,ARang)
- {
- if(sInfo[playerid][padmin] >= ARang) return 1;
- return 0;
- }
- public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
- {
- if(playertextid == t_auswahl2)
- {
- CancelSelectTextDraw(playerid);
- PlayerTextDrawHide(playerid, t_auswahl1);
- PlayerTextDrawHide(playerid, t_auswahl2);
- PlayerTextDrawHide(playerid, t_auswahl3);
- PlayerTextDrawHide(playerid, t_auswahl4);
- PlayerTextDrawHide(playerid, t_auswahl5);
- SendClientMessage(playerid,COLOR_YELLOW,"Team Kriminell");
- return 1;
- }else if(playertextid == t_auswahl3)
- {
- CancelSelectTextDraw(playerid);
- PlayerTextDrawHide(playerid, t_auswahl1);
- PlayerTextDrawHide(playerid, t_auswahl2);
- PlayerTextDrawHide(playerid, t_auswahl3);
- PlayerTextDrawHide(playerid, t_auswahl4);
- PlayerTextDrawHide(playerid, t_auswahl5);
- SendClientMessage(playerid,COLOR_YELLOW,"Team Polizei");
- }
- return 1;
- }
- //BEFEHLE
- COMMAND:veh(playerid,params[])
- {
- new ModelID, color[2],Float:VehPos[4], vehicleid;
- if(GetPlayerState(playerid)!=PLAYER_STATE_ONFOOT) return SendClientMessage(playerid,0xB0AFB0FF,"Du bist nicht zu Fuss");
- if(sscanf(params, "ddd",ModelID,color[0],color[1])) return SendClientMessage(playerid,0xB0AFB0FF, "/veh [vehicleid] [color1] [color2]");
- if(ModelID < 400 || ModelID > 611) return SendClientMessage(playerid,0xB0AFB0FF, "Die Fahrzeug Id muss von 400 bis 611 sein");
- if(color[0] < 0 || color[0] > 126 || color[1] < 0 || color[1] > 126) return SendClientMessage(playerid,0xB0AFB0FF, "the colorid must be between 0 - 126");
- GetPlayerPos(playerid, VehPos[0],VehPos[1],VehPos[2]);
- GetPlayerFacingAngle(playerid, VehPos[3]);
- vehicleid = CreateVehicle(ModelID,VehPos[0],VehPos[1],VehPos[2],VehPos[3],color[0],color[1],-1);
- LinkVehicleToInterior(vehicleid,GetPlayerInterior(playerid));
- SetVehicleVirtualWorld(vehicleid,GetPlayerVirtualWorld(playerid));
- PutPlayerInVehicle(playerid, vehicleid, 0);
- return 1;
- }
- COMMAND:motor(playerid,params[])
- {
- new t_engine,t_lights,t_alarm,t_doors,t_boonet,t_boot,t_object;
- new vID = GetPlayerVehicleID(playerid);
- if(sInfo[playerid][peingeloggt] == 0) return SendClientMessage(playerid,COLOR_GREY," Du bist nicht eingeloggt!");
- if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid,COLOR_GREY," Du bist nicht der Fahrer dest Fahrzeuges!");
- GetVehicleParamsEx(vID,t_engine,t_lights,t_alarm,t_doors,t_boonet,t_boot,t_object);
- if(t_engine == 1)
- {
- t_engine = 0;
- SendClientMessage(playerid,COLOR_YELLOW,"Motor ausgeschaltet!");
- }else{
- t_engine = 1;
- SendClientMessage(playerid,COLOR_YELLOW,"Motor angeschaltet!");
- }
- SetVehicleParamsEx(vID,t_engine,t_lights,t_alarm,t_doors,t_boonet,t_boot,t_object);
- return 1;
- }
- COMMAND:licht(playerid,params[])
- {
- new t_engine,t_lights,t_alarm,t_doors,t_boonet,t_boot,t_object;
- new vID = GetPlayerVehicleID(playerid);
- if(sInfo[playerid][peingeloggt] == 0) return SendClientMessage(playerid,COLOR_GREY," Du bist nicht eingeloggt!");
- if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid,COLOR_GREY," Du bist nicht der Fahrer dest Fahrzeuges!");
- GetVehicleParamsEx(vID,t_engine,t_lights,t_alarm,t_doors,t_boonet,t_boot,t_object);
- if(t_lights == 1)
- {
- t_lights = 0;
- SendClientMessage(playerid,COLOR_YELLOW,"Licht ausgeschaltet!");
- }else{
- t_lights = 1;
- SendClientMessage(playerid,COLOR_YELLOW,"Licht angeschaltet!");
- }
- SetVehicleParamsEx(vID,t_engine,t_lights,t_alarm,t_doors,t_boonet,t_boot,t_object);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement