Ich habe mein Script jetzt so --- würde es jetzt das Nummernschild auch mit speichern oder nicht?
// Variablen
#pragma warning disable 239
#pragma warning disable 214
//Includes
#include <a_samp>
#include <ocmd>
#include <sscanf2>
#include <a_mysql>
//enums
enum playerInfo{
eingeloggt,
level,
db_id,
alevel
}
enum CarEnum{
id_x,
model,
besitzer,
Float:c_y,
Float:c_x,
Float:c_z,
Float:c_r,
numplate,
db_id
}
enum Bizzes{
Float:b_x,
Float:b_y,
Float:b_z,
Float:b_ix,
Float:b_iy,
Float:b_iz,
b_interior,
b_shopname[15]
}
enum autohausEnum{
Float:s_x,
Float:s_y,
Float:s_z,
Float:s_r
}
enum autohauscarEnum{
model,
Float:c_x,
Float:c_y,
Float:c_z,
Float:c_r,
c_preis,
ah_id,
id_x
}
//Globale Variablen
new dbhandle;
new sInfo[MAX_PLAYERS][playerInfo];
new sekunden_timer;
/*new scar[][] = {
"400",
"401",
"402",
"403"
};*/
new bInfo[][Bizzes] = {
{242.2958,-178.5242,1.5781,285.6146,-86.3010,1001.5229,4,"FDCHICK"}, //Ammunat
{172.3489,-152.4089,1.5739,-27.3352,-31.2847,1003.5573,4,"FDCHICK"} // Dring (24/7)
};
new ahInfo[][autohausEnum] = {
{125.5168,-170.5950,1.3504,178.6866}, // id 0 - Autohaus 1
{189.7878,-255.4492,1.3493,177.4342} //id 1 - Autohaus 2
};
new ahCars[][autohauscarEnum] = {
{415,114.3326,-151.0970,1.3506,181.0839,1300,0},
{411,96.9697,-155.0146,2.3497,266.9514,2400,0},
{400,218.2797,-261.1500,1.3495,93.9186,700,1},
{416,209.2061,-268.2490,1.3506,4.8820,3000,1}
};
new cInfo[50][CarEnum];
//Farben
#define COLOR_RED 0xFF0000FF
//Dialoge
#define DIALOG_TELEPORT 1
#define DIALOG_REGISTER 2
#define DIALOG_LOGIN 3
#define DIALOG_AUTOHAUS 4
//MySQL
#define db_host "xxxxxxx"
#define db_user "xxxxx"
#define db_pass "xxxxxxxx"
#define db_db "xxxxxxx"
//Zufallsfunktion
#define randomEx(%0,%1) (random((%1) - (%0) + 1) + (%0))
//Forwards
forward OnUserCheck(playerid);
forward OnPasswordResponse(playerid);
forward carSavedToDB(carid);
forward OnPlayerCarsLoaded(playerid);
forward sekunde();
forward unFreezePlayer(playerid);
stock const ValidVehicles[] = {
416, // ambulan
445, // admiral
602, // alpha
568, // bandito
429, // banshee
499, // benson
424, // bfinject
536, // blade
496, // blistac
504, // bloodra
422, // bobcat
609, // boxburg
498, // boxville
401, // bravura
575, // broadway
518, // buccanee
402, // buffalo
541, // bullet
482, // burrito
438, // cabbie
457, // caddy
527, // cadrona
483, // camper
524, // cement
415, // cheetah
542, // clover
589, // club
480, // comet
578, // dft30
486, // dozer
507, // elegant
562, // elegy
585, // emperor
527, // enforcer
419, // esperant
587, // euros
533, // feltzer
565, // flash
455, // flatbed
530, // forklift
526, // fortune
466, // glendale
604, // glenshit
492, // greenwoo
474, // hermes
434, // hotknife
502, // hotrina
503, // hotrinb
494, // hotring
579, // huntley
545, // hustler
411, // infernus
546, // intruder
559, // jester
508, // journey
571, // kart
400, // landstal
517, // majestic
410, // manana
551, // merit
500, // mesa
418, // moonbeam
572, // mower
423, // mrwhoop
516, // nebula
582, // newsvan
467, // oceanic
404, // peren
603, // phoenix
600, // picador
413, // pony
426, // premier
436, // previon
547, // primo
489, // rancher
479, // regina
534, // remingtn
505, // rnchlure
442, // romero
440, // rumpo
475, // sabre
543, // sadler
605, // sadlshit
495, // sandking
567, // savanna
428, // securica
405, // sentinel
535, // slamvan
458, // solair
580, // stafford
439, // stallion
561, // stratum
409, // stretch
560, // sultan
550, // sunrise
506, // supergt
601, // swatvan
574, // sweeper
566, // tahoma
549, // tampa
420, // taxi
459, // topfun
576, // tornado
451, // turismo
558, // uranus
540, // vincent
491, // virgo
412, // voodoo
478, // walton
421, // washing
529, // willard
555, // windsor
456, // yankee
554, // yosemite
477, // zr350
588, // hotdog
437, // coach
532, // combine
433, // barracks
414, // mule
443, // packer
470, // patriot
432, // rhino
525, // towtruck
408, // trash
406, // dumper
573, // duneride
444, // monster
556, // monstera
557, // monsterb
471, // Bzggy
}; //Oben im Skript
main()
{
}
//AddStaticVehicle
//CreateVehicleEx
//CreateVehicle
new ABC[26][0] = {
{"A"}, {"B"}, {"C"}, {"D"}, {"E"}, {"F"}, {"G"}, {"H"}, {"I"}, {"J"}, {"K"}, {"L"}, {"M"},
{"N"}, {"O"}, {"P"}, {"Q"}, {"R"}, {"S"}, {"T"}, {"U"}, {"V"}, {"W"}, {"X"}, {"Y"}, {"Z"}
};
public OnGameModeInit()
{
SetGameModeText("MrMonat Tutorialmode");
AddPlayerClass(1,199.0846,-150.0331,1.5781,359.1443,WEAPON_MP5,500,0,0,0,0);
AddPlayerClass(2,199.0846,-150.0331,1.5781,359.1443,WEAPON_MP5,500,0,0,0,0);
AddPlayerClass(3,199.0846,-150.0331,1.5781,359.1443,WEAPON_MP5,500,0,0,0,0);
DisableInteriorEnterExits();
ManualVehicleEngineAndLights();
//Gebäude laden eingänge...
for(new i=0; i<sizeof(bInfo); i++)
{
CreatePickup(1239,1,bInfo[i][b_x],bInfo[i][b_y],bInfo[i][b_z]);
Create3DTextLabel("Zum Betreteten schreibe /enter",0x000FFFFF,bInfo[i][b_x],bInfo[i][b_y],bInfo[i][b_z],10,0,1);
}
//Gebäudeladen Ausgänge
for(new a=0; a<sizeof(bInfo); a++)
{
CreatePickup(1239,1,bInfo[a][b_ix],bInfo[a][b_iy],bInfo[a][b_iz]);
Create3DTextLabel("Zum Verlassen schreibe /Exit",0x000FFFFF,bInfo[a][b_ix],bInfo[a][b_iy],bInfo[a][b_iz],10,0,1);
}
//Autohäuser laden
for(new i=0; i<sizeof(ahCars); i++)
{
new zahl1 = random(9);
new zahl2 = random(9);
new zahl3 = random(9);
new zahl4 = random(9);
new Alpha1 = random(26);
new Alpha2 = random(26);
new Alpha3 = random(26);
new Alpha4 = random(26);
new Alpha5 = random(26);
new smodel = ValidVehicles[random(sizeof(ValidVehicles))];
//carmodel = randomEx(400, 609);
//type = GetVehicleModel(carmodel)
//if(type != VEHICLE_TYPE_PLANE)continue;
//ahCars[i][id_x]=AddStaticVehicle(ahCars[i][model], ahCars[i][c_x], ahCars[i][c_y], ahCars[i][c_z], ahCars[i][c_r], -1, -1);
ahCars[i][id_x]=AddStaticVehicle(smodel, ahCars[i][c_x], ahCars[i][c_y], ahCars[i][c_z], ahCars[i][c_r], -1, -1);
new plate[125];
format(plate,sizeof(plate),"%s%s-%i%i%s%s%i%i%s",ABC[Alpha1],ABC[Alpha2],zahl1,zahl2,ABC[Alpha3],ABC[Alpha4],zahl3,zahl4,ABC[Alpha5]);
SetVehicleNumberPlate(ahCars[i][id_x], plate);
}
//Timer
//sekunden_timer = SetTimer("sekunde", 1000, true);
//Autos Erstellen
AddStaticVehicle(510,249.0886,-158.1434,1.6657,268.9586,-1,-1); // Sultan
//MySQL
dbhandle = mysql_connect(db_host,db_user,db_db,db_pass);
return 1;
}
ocmd:stoptimer(playerid,params[])
{
KillTimer(sekunden_timer);
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 sekunde()
{
printf("TimeStamp: %i", gettime());
return 1;
}
public OnPlayerConnect(playerid)
{
new nachricht[128];
format(nachricht,sizeof(nachricht),"Du bist mit der ID %i verbunden.",playerid);
SendClientMessage(playerid,COLOR_RED,nachricht);
//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][eingeloggt]==0)return 1;
//Speichern level,money
new query[128];
format(query,sizeof(query),"UPDATE user SET level='%i',money='%i',alevel='%i' WHERE id='%i'",sInfo[playerid][level],GetPlayerMoney(playerid),sInfo[playerid][alevel],sInfo[playerid][db_id]);
mysql_function_query(dbhandle,query,false,"","");
return 1;
}
resetPlayer(playerid)
{
//sInfo[playerid][level]=0;
//sInfo[playerid][eingeloggt]=0;
//sInfo[playerid][id]=0;
//sInfo[playerid][alevel]=0;
for(new i=0; i<sizeof(sInfo[]); i++)
{
sInfo[playerid][playerInfo:i]=0;
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
for(new i=0; i<sizeof(cInfo); i++)
{
if(cInfo[i][id_x]==0)continue;
if(cInfo[i][besitzer]!=sInfo[playerid][db_id])continue;
GetVehiclePos(cInfo[i][id_x],cInfo[i][c_x],cInfo[i][c_y],cInfo[i][c_z]);
GetVehicleZAngle(cInfo[i][id_x],cInfo[i][c_r]);
new query[128];
format(query,sizeof(query),"UPDATE autos SET x='%f',y='%f',z='%f',r='%f',numplate='%d' WHERE id='%i'",cInfo[i][c_x],cInfo[i][c_y],cInfo[i][c_z],cInfo[i][c_r],cInfo[i][numplate],cInfo[i][db_id]);
printf(query);
mysql_function_query(dbhandle,query,false,"","");
DestroyVehicle(cInfo[i][id_x]);
cInfo[i][id_x]=0;
}
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;
}
//Befehle
ocmd:motor(playerid,params[])
{
if(GetPlayerState(playerid)!=PLAYER_STATE_DRIVER)return
SendClientMessage(playerid, COLOR_RED, "Du bist nicht der Fahrer eines Fahrzeuges");
//motor An/aus
new vID=GetPlayerVehicleID(playerid),
tmp_engine,
tmp_lights,
tmp_alarm,
tmp_doors,
tmp_bonnet,
tmp_boot,
tmp_objective;
GetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
if(tmp_engine==1){
tmp_engine = 0;
}else{
tmp_engine = 1;
}
SetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
return 1;
}
ocmd:licht(playerid,params[])
{
if(GetPlayerState(playerid)!=PLAYER_STATE_DRIVER)return
SendClientMessage(playerid, COLOR_RED, "Du bist nicht der Fahrer eines Fahrzeuges");
//motor An/aus
new vID=GetPlayerVehicleID(playerid),
tmp_engine,
tmp_lights,
tmp_alarm,
tmp_doors,
tmp_bonnet,
tmp_boot,
tmp_objective;
GetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
if(tmp_lights==1){
tmp_lights = 0;
}else{
tmp_lights = 1;
}
SetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
return 1;
}
ocmd:nummer(playerid,params[])
{
new nummer = randomEx(400, 609);
//new smodel = ValidVehicles[random(sizeof(ValidVehicles))];
//new randMSG = random(sizeof(s_car));
//SendClientMessageToAll(COLOR_RED, scar[smodel]); // Replace the "COLOR" with your defined color.
new string[128];
//new Float:x,Float:y,Float:z;
//GetPlayerPos(playerid,x,y,z);
//AddStaticVehicle(smodel,x,y,z,0, -1, -1);
format(string,sizeof(string),"Die Zufallszahl lautet: %i.", nummer);
SendClientMessage(playerid,COLOR_RED,string);
return 1;
}
public unFreezePlayer(playerid)
{
TogglePlayerControllable(playerid, true);
return 1;
}
ocmd:freezeme(playerid,params[])
{
TogglePlayerControllable(playerid, false);
SetTimerEx("unFreezePlayer", 3000, false, "i", playerid);
return 1;
}
ocmd:teleport(playerid,params[])
{
if(!isAdmin(playerid,2))return SendClientMessage(playerid,COLOR_RED,"Dein Adminrang ist zu niedrig.");
ShowPlayerDialog(playerid,DIALOG_TELEPORT,DIALOG_STYLE_LIST,"Teleport","Spawn\nFarm","Teleport","Abbrechen");
return 1;
}
ocmd:exit(playerid,params[])
{
for(new i=0; i<sizeof(bInfo); i++)
{
if(GetPlayerVirtualWorld(playerid)!=i)continue;
if(!IsPlayerInRangeOfPoint(playerid,2, bInfo[i][b_ix], bInfo[i][b_iy], bInfo[i][b_iz]))continue;
SetPlayerPos(playerid, bInfo[i][b_x], bInfo[i][b_y], bInfo[i][b_z]);
SetPlayerInterior(playerid,0);
SetPlayerVirtualWorld(playerid, 0);
return 1;
}
return 1;
}
ocmd:enter(playerid,params[])
{
for(new i=0; i<sizeof(bInfo); i++)
{
if(!IsPlayerInRangeOfPoint(playerid,2, bInfo[i][b_x], bInfo[i][b_y], bInfo[i][b_z]))continue;
SetPlayerPos(playerid, bInfo[i][b_ix], bInfo[i][b_iy], bInfo[i][b_iz]);
SetPlayerInterior(playerid,bInfo[i][b_interior]);
SetPlayerVirtualWorld(playerid, i);
SetPlayerShopName(playerid, bInfo[i][b_shopname]);
return 1;
}
return 1;
}
public carSavedToDB(carid)
{
cInfo[carid][db_id]=cache_insert_id(dbhandle);
return 1;
}
saveCarToDB(playerid,carid)
{
new query[128];
format(query,sizeof(query), "INSERT INTO autos (besitzer,model,x,y,z,r,numplate) VALUES ('%i','%i','%f','%f','%f','%f','%d')", sInfo[playerid][db_id],cInfo[carid][model],cInfo[carid][c_x],cInfo[carid][c_y],cInfo[carid][c_z],cInfo[carid][c_r],cInfo[carid][numplate]);
mysql_function_query(dbhandle,query,true,"carSavedToDB","i",carid);
return 1;
}
createPlayerCar(playerid,modelid,Float:x,Float:y,Float:z,Float:r)
{
for(new i=0; i<sizeof(cInfo); i++)
{
if(cInfo[i][id_x]!=0)continue;
cInfo[i][besitzer]=sInfo[playerid][db_id];
//format(cInfo[i][besitzer],MAX_PLAYER_NAME,"%s",name);
cInfo[i][c_x]=x;
cInfo[i][c_y]=y;
cInfo[i][c_z]=z;
cInfo[i][c_r]=r;
//cInfo[i][numplate]==
cInfo[i][model]=modelid;
cInfo[i][id_x] = CreateVehicle(modelid,x,y,z,r,-1,-1,-1);
new string[128];
format(string,sizeof(string), "Das Auto cInfo[%i] wurde erstellt",i);
SendClientMessageToAll(COLOR_RED,string);
saveCarToDB(playerid,i);
return 1;
}
return 1;
}
ocmd:delcar(playerid,params[])
{
if(!isAdmin(playerid,3))return SendClientMessage(playerid,COLOR_RED,"Dein Adminrang ist zu niedrig.");
if(!IsPlayerInAnyVehicle(playerid))return SendClientMessage(playerid, COLOR_RED, "Du Bist in Keinem Fahrzeug");
DestroyVehicle(GetPlayerVehicleID(playerid));
return 1;
}
ocmd:pn(playerid,params[])
{
new pID,text[128];
if(sscanf(params,"us[128]",pID,text))return SendClientMessage(playerid,COLOR_RED,"INFO: /pn [playerid] [text]");
SendClientMessage(pID,COLOR_RED,text);
return 1;
}
ocmd:setadmin(playerid,params[])
{
if(!isAdmin(playerid,3))return SendClientMessage(playerid,COLOR_RED,"Dein Adminrang ist zu niedrig.");
new pID,a_level;
if(sscanf(params,"ui",pID,a_level))return SendClientMessage(playerid,COLOR_RED,"INFO: /setadmin [playerid] [adminlevel]");
sInfo[pID][alevel]=a_level;
savePlayer(pID);
SendClientMessage(pID,COLOR_RED,"Dein Adminrang wurde geändert.");
SendClientMessage(playerid,COLOR_RED,"Du hast den Adminrang geändert.");
return 1;
}
isAdmin(playerid,a_level)
{
if(sInfo[playerid][alevel]>=a_level)return 1;
return 0;
}
ocmd:createcar(playerid,params[])
{
if(!isAdmin(playerid,3))return SendClientMessage(playerid,COLOR_RED,"Dein Adminrang ist zu niedrig.");
//new CarID,pID;
new CarID,pID;
//if(sscanf(params,"i",CarID))return SendClientMessage(playerid,COLOR_RED,"INFO: /createcar [playerid] [carid]");
if(sscanf(params,"ui",pID,CarID))return SendClientMessage(playerid,COLOR_RED,"INFO: /createcar [playerid] [carid]");
if(CarID<400||CarID>611)return SendClientMessage(playerid,COLOR_RED,"Ungültiges Model!");
new Float:cx,Float:cy,Float:cz,Float:cr;
//GetPlayerPos(CarID,cx,cy,cz);
GetPlayerPos(pID,cx,cy,cz);
GetPlayerFacingAngle(pID,cr);
//GetPlayerFacingAngle(CarID,cr);
//CreateVehicle(CarID,cx+2,cy+2,cz,cr,-1,-1,-1);
createPlayerCar(pID,CarID,cx,cy,cz,cr);
return 1;
}
ocmd:restart(playerid,params[])
{
if(!isAdmin(playerid,3))return SendClientMessage(playerid,COLOR_RED,"Dein Adminrang ist zu niedrig.");
SendRconCommand("gmx");
return 1;
}
ocmd:test(playerid,params[])
{
SendClientMessage(playerid,COLOR_RED,"Du hast /test eingegeben.");
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)
{
if(newstate==PLAYER_STATE_DRIVER)
{
new vID=GetPlayerVehicleID(playerid);
for(new i=0; i<sizeof(ahCars); i++)
{
if(ahCars[i][id_x]!=vID)continue;
//VerkaufsProzess
SetPVarInt(playerid,"BuyCarID",i);
new string[256];
format(string,sizeof(string),"Möchtest du das Fahrzeug für %i$ kaufen?",ahCars[i][c_preis]);
ShowPlayerDialog(playerid, DIALOG_AUTOHAUS, DIALOG_STYLE_MSGBOX, "Autoverkauf", string, "ja", "nein");
break;
}
return 1;
}
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_YES)
{
ocmd_enter(playerid,"");
//Enter Befehk
return 1;
}
if(newkeys & KEY_NO)
{
ocmd_exit(playerid,"");
//Exitbefehl
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;
}
getFreeCarid()
{
for(new i=0; i<sizeof(cInfo); i++)
{
if(cInfo[i][id_x]==0)return 1;
}
return 0;
}
public OnPlayerCarsLoaded(playerid)
{
new num_rows,num_fields;
cache_get_data(num_rows,num_fields,dbhandle);
if(!num_rows)return 1;
for(new i=0; i<num_rows; i++)
{
new id=getFreeCarid();
cInfo[id][model]=cache_get_field_content_int(i,"model",dbhandle);
cInfo[id][besitzer]=cache_get_field_content_int(i,"besitzer",dbhandle);
cInfo[id][c_x]=cache_get_field_content_float(i,"x",dbhandle);
cInfo[id][c_y]=cache_get_field_content_float(i,"y",dbhandle);
cInfo[id][c_z]=cache_get_field_content_float(i,"z",dbhandle);
cInfo[id][c_r]=cache_get_field_content_float(i,"r",dbhandle);
cInfo[id][numplate]=cache_get_field_content_int(i,"numplate",dbhandle);
cInfo[id][db_id]=cache_get_field_content_int(i,"id",dbhandle);
cInfo[id][id_x]=CreateVehicle(cInfo[id][model],cInfo[id][c_x],cInfo[id][c_y],cInfo[id][c_z],cInfo[id][c_r],-1,-1,-1);
}
return 1;
}
loadPlayerCars(playerid)
{
new query[128];
format(query,sizeof(query),"SELECT * FROM autos WHERE besitzer='%i'", sInfo[playerid][db_id]);
mysql_function_query(dbhandle, query, true, "OnPlayerCarsLoaded", "i", playerid);
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][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);
loadPlayerCars(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;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid==DIALOG_AUTOHAUS)
{
if(response)
{
//Autoverkauf
new id=GetPVarInt(playerid, "buyCarID");
if(GetPlayerMoney(playerid)<ahCars[id][c_preis])
{
SendClientMessage(playerid, COLOR_RED, "Du hast das Geld leider nicht!");
RemovePlayerFromVehicle(playerid);
return 1;
}
GivePlayerMoney(playerid,-ahCars[id][c_preis]);
createPlayerCar(playerid,ahCars[id][model],ahInfo[ahCars[id][ah_id]][s_x],ahInfo[ahCars[id][ah_id]][s_y],ahInfo[ahCars[id][ah_id]][s_z],ahInfo[ahCars[id][ah_id]][s_r]);
SendClientMessage(playerid, COLOR_RED, "Herzlichen Gllückstrumpf zur neuen Karre! xD");
RemovePlayerFromVehicle(playerid);
}
else
{
//Autorauswurf
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "Dann eben nicht.....");
}
return 1;
}
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=MD5('%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',MD5('%s')) ",name,passwort);
mysql_function_query(dbhandle,query,false,"","");
}
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;
}
if(dialogid==DIALOG_TELEPORT)
{
if(response)
{
if(listitem==0)
{
//Spawn
SetPlayerPos(playerid,199.0846,-150.0331,1.5781);
}
if(listitem==1)
{
//Farm
SetPlayerPos(playerid,0.0,0.0,6.0);
}
}
else
{
SendClientMessage(playerid,COLOR_RED,"Vorgang abgebrochen.");
}
return 1;
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
Alles anzeigen