//-----------------------------------------
#include <a_samp>
#include <dini>
#include <ocmd>
//-----------------------------------------
#define BLAU 0x0087FFFF
#define ROT 0xE10000FF
#define ORANGE 0xFF9600FF
#define WEISS 0xFEFEFEFF
//-----------------------------------------
#define DIALOG_TUTORIAL 1
#define DIALOG_REGISTER 2
#define DIALOG_LOGIN 3
//-----------------------------------------
#define fraktname1 "LSPD"
#define fraktname2 "Mafia"
#define fraktname3 "Medic"
//-----------------------------------------
#define mafiaspawn 1188.7655,-943.9813,42.7585
#define lspdspawn 1520.0, 1541.0, 1655.0
#define medicspawn 1520.0,1568.0,1510.0
//-----------------------------------------
forward abwerben();
//-----------------------------------------
new bsnenter;
new bsnexit;
//-----------------------------------------
main()
{
print("\n----------------------------------");
print("TutorialServer");
print("----------------------------------\n");
}
public OnGameModeInit()
{
UsePlayerPedAnims();
bsnexit=CreatePickup(1559,1,362.8524,-75.1179,1001.5078);
bsnenter=CreatePickup(1559,1,1199.2235,-918.1543,43.1233);
Create3DTextLabel("BSN\n Eingang",BLAU,1199.2235,-918.1543,43.1233,10,0);
DisableInteriorEnterExits();
SetGameModeText("TutorialMode");
AddPlayerClass(0,2047.4270,1336.5569,10.6719,188.9284,0,0,0,0,0,0); // position;
AddPlayerClass(1,2047.4270,1336.5569,10.6719,188.9284,25,200,0,0,0,0); // position
SetTimer("abwerben",900000*60*10,true);
return 1;
}
public abwerben()
{
SendClientMessageToAll(ORANGE,"|__________AbWerben__________|");
SendClientMessageToAll(WEISS,"**Abwerben ist hier verboten,**");
SendClientMessageToAll(WEISS,"**wer dieses tut wird sofort gebannt!**");
SendClientMessageToAll(WEISS,"**Mit Freundlichen Grüßen:Das Admin Team**");
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
if(IsPlayerNPC(playerid))return 1;
SetPlayerPos(playerid,2047.4270,1336.5569,10.6719);
SetPlayerFacingAngle(playerid,188.9284);
SetPlayerCameraPos(playerid,2047.6205,1333.3314,10.6719);
SetPlayerCameraLookAt(playerid,2047.4270,1336.5569,10.6719);
return 1;
}
public OnPlayerConnect(playerid)
{
if(IsPlayerNPC(playerid))return 1;
new Spielerdatei[64];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(Spielerdatei,sizeof(Spielerdatei),"/Accounts/%s.txt",name);
if(dini_Exists(Spielerdatei))
{
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Dein Account wurde gefunden. Gib bitte das Passwort ein.","Login","Abbrechen");
}
else
{
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Registrieren","Gib bitte das gewünschte Passwort ein:","Register","Abbrechen");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(GetPVarInt(playerid,"loggedin")==1)
{
SpielerSpeichern(playerid);
}
return 1;
}
public OnPlayerSpawn(playerid)
{
if(!strcmp(SpielerName(playerid),"TutorialBot",true))
{
PutPlayerInVehicle(playerid,botauto,0);
}
if(IsPlayerNPC(playerid))return 1;
switch(GetPVarInt(playerid,"Fraktion"))
{
case 0:{}
case 1:{SetPlayerPos(playerid,lspdspawn);SetPlayerColor(playerid,BLAU);}
case 2:{SetPlayerPos(playerid,mafiaspawn);GivePlayerWeapon(playerid,24,100);}
case 3:{SetPlayerPos(playerid,medicspawn);SetPlayerColor(playerid,ROT);}
}
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;
}
ocmd:f(playerid,params[])
{
new text[128];
if(sscanf(params,"s",text))return SendClientMessage(playerid,ROT,"/f [text]");
format(text,sizeof(text),"Member %s: %s",SpielerName(playerid),text);
for(new i=0; i<GetMaxPlayers(); i++)
{
if(IsPlayerConnected(i))
{
if(isPlayerInFrakt(i,GetPVarInt(playerid,"Fraktion")))
{
SendClientMessage(i,BLAU,text);
}
}
}
return 1;
}
ocmd:makeleader(playerid,params[])
{
if(!isPlayerAnAdmin(playerid,6))return SendClientMessage(playerid,ROT,"Rang zu Niedrig.");
new pID,fID;
if(sscanf(params,"ui",pID,fID))return SendClientMessage(playerid,BLAU,"/makeleader [playerid] [fraktionsid]");
SetPVarInt(pID,"Fraktion",fID);
SendClientMessage(playerid,BLAU,"Erfolgreich.");
return 1;
}
ocmd:setadmin(playerid,params[])
{
if(!isPlayerAnAdmin(playerid,6))return SendClientMessage(playerid,ROT,"Du bist kein Admin.");
new pID, rank;
if(sscanf(params,"ui",pID,rank))return SendClientMessage(playerid,ROT,"/setadmin [spieler] [level]");
if(rank<1||rank>5)return SendClientMessage(playerid,ROT,"Bitte gültigen Rang angeben.");
SetPVarInt(pID,"Adminlevel",rank);
SpielerSpeichern(pID);
SendClientMessageToAll(BLAU,"Es wurde jemand zu Admin gemacht.");
return 1;
}
ocmd:ban(playerid,params[])
{
if(!isPlayerAnAdmin(playerid,2))return SendClientMessage(playerid,ROT,"Du bist kein Admin.");
new pID, reason[128],string[128];
if(sscanf(params,"us",pID,reason))return SendClientMessage(playerid,BLAU,"/ban [id] [grund]");
format(string,sizeof(string),"AdmCmd: %s wurde von %s gebannt. Grund: %s",SpielerName(pID),SpielerName(playerid),reason);
SendClientMessageToAll(ROT,string);
SetPVarInt(pID,"Baned",1);
Kick(pID);
return 1;
}
ocmd:kick(playerid,params[])
{
if(!isPlayerAnAdmin(playerid,2))return SendClientMessage(playerid,ROT,"Du bist kein Admin.");
new pID, reason[128],string[128];
if(sscanf(params,"us",pID,reason))return SendClientMessage(playerid,BLAU,"/kick [id] [grund]");
format(string,sizeof(string),"AdmCmd: %s wurde von %s gekickt. Grund: %s",SpielerName(pID),SpielerName(playerid),reason);
SendClientMessageToAll(ROT,string);
Kick(pID);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext,"/bsn",true)==0)
{
if(isPlayerAnAdmin(playerid,3))
{
ShowPlayerDialog(playerid,DIALOG_TUTORIAL,DIALOG_STYLE_MSGBOX,"BSN","Möchten sie wirklich zum BSN?","JA","NEIN");
return 1;
}
SendClientMessage(playerid,BLAU,"Du bist kein Admin.");
return 1;
}
if(strcmp(cmdtext,"/restart",true)==0)
{
if(isPlayerAnAdmin(playerid,6))
{
SendRconCommand("gmx");
return 1;
}
SendClientMessage(playerid,BLAU,"Du bist kein Admin.");
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate==PLAYER_STATE_DRIVER)
{
for(new i=0; i<sizeof(mafiacar); i++)
{
if(GetPlayerVehicleID(playerid)==mafiacar[i])
{
if(GetPVarInt(playerid,"Fraktion")!=2)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid,ROT,"Du darfst dieses Fahrzeug nicht fahren.");
}
}
}
}
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)
{
if(pickupid==bsnenter)
{
SetPlayerPos(playerid,375.962463,-65.816848,1001.507812);
SetPlayerInterior(playerid,10);
GameTextForPlayer(playerid,"~w~Du ~r~hast ~b~den ~n~~g~BSN betreten.",3000,3);
}
if(pickupid==bsnexit)
{
SetPlayerPos(playerid,1199.4618,-920.8215,43.1059);
SetPlayerFacingAngle(playerid,185.7090);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid,0);
}
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)
{
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;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid==DIALOG_LOGIN)
{
if(response==0)
{
SendClientMessage(playerid,BLAU,"Du hast den Vorgang abgebrochen.");
Kick(playerid);
return 1;
}
if(response==1)
{
if(!strlen(inputtext))
{
SendClientMessage(playerid,BLAU,"Das Passwort war nicht lang genug.");
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Dein Account wurde gefunden. Gib bitte das Passwort ein.","Login","Abbrechen");
return 1;
}
else
{
Login(playerid,inputtext);
return 1;
}
}
}
if(dialogid==DIALOG_REGISTER)
{
if(response==0)
{
SendClientMessage(playerid,BLAU,"Du hast den Vorgang abgebrochen.");
Kick(playerid);
return 1;
}
if(response==1)
{
if(!strlen(inputtext))
{
SendClientMessage(playerid,BLAU,"Das Passwort war nicht lang genug.");
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Registrieren","Gib bitte das gewünschte Passwort ein:","Register","Abbrechen");
return 1;
}
else
{
Register(playerid,inputtext);
return 1;
}
}
}
if(dialogid==DIALOG_TUTORIAL)
{
if(response==1)
{
SetPlayerPos(playerid,1227.1797,-914.0590,42.6812);
SendClientMessage(playerid,0xFFFF00FF,"Du wurdest Teleportiert");
}
if(response==0)
{
SendClientMessage(playerid,BLAU,"Ok dann halt nicht...");
}
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
stock SpielerName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
return name;
}
stock Register(playerid,key[])
{
new Spielerdatei[64];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(Spielerdatei,sizeof(Spielerdatei),"/Accounts/%s.txt",name);
dini_Create(Spielerdatei);
dini_Set(Spielerdatei,"Passwort",key);
SendClientMessage(playerid,BLAU,"Erfolgreich registriert.");
SetPlayerScore(playerid,0);
SetPVarInt(playerid,"loggedin",1);
return 1;
}
stock Login(playerid,key[])
{
new Spielerdatei[64];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(Spielerdatei,sizeof(Spielerdatei),"/Accounts/%s.txt",name);
if(!strcmp(key,dini_Get(Spielerdatei,"Passwort"),false))
{
LoadAccount(playerid);
SendClientMessage(playerid,BLAU,"Erfolgreich eingeloggt.");
return 1;
}
else
{
SendClientMessage(playerid,BLAU,"Falsches Passwort.");
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Dein Account wurde gefunden. Gib bitte das Passwort ein.","Login","Abbrechen");
return 1;
}
}
stock LoadAccount(playerid)
{
new Spielerdatei[64];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(Spielerdatei,sizeof(Spielerdatei),"/Accounts/%s.txt",name);
SetPlayerScore(playerid,dini_Int(Spielerdatei,"Level"));
GivePlayerMoney(playerid,dini_Int(Spielerdatei,"Geld"));
SetPVarInt(playerid,"Adminlevel",dini_Int(Spielerdatei,"Adminlevel"));
SetPVarInt(playerid,"Fraktion",dini_Int(Spielerdatei,"Fraktion"));
SetPVarInt(playerid,"Baned",dini_Int(Spielerdatei,"Baned"));
if(GetPVarInt(playerid,"Baned")==1)
{
SendClientMessage(playerid,ROT,"Du bist vom Server gebannt.");
Kick(playerid);
}
SetPVarInt(playerid,"loggedin",1);
return 1;
}
stock SpielerSpeichern(playerid)
{
if(GetPVarInt(playerid,"loggedin")==1)
{
new Spielerdatei[64];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(Spielerdatei,sizeof(Spielerdatei),"/Accounts/%s.txt",name);
dini_IntSet(Spielerdatei,"Level",GetPlayerScore(playerid));
dini_IntSet(Spielerdatei,"Geld",GetPlayerMoney(playerid));
dini_IntSet(Spielerdatei,"Adminlevel",GetPVarInt(playerid,"Adminlevel"));
dini_IntSet(Spielerdatei,"Fraktion",GetPVarInt(playerid,"Fraktion"));
dini_IntSet(Spielerdatei,"Baned",GetPVarInt(playerid,"Baned"));
}
return 1;
}
stock isPlayerInFrakt(playerid,fraktid)
{
if(GetPVarInt(playerid,"Fraktion")==fraktid)return 1;
return 0;
}
stock isPlayerAnAdmin(playerid,rang)
{
if(GetPVarInt(playerid,"Adminlevel")>=rang)return 1;
return 0;
}
stock sscanf(sstring[], format[], {Float,_}:...)
{
#if defined isnull
if (isnull(sstring))
#else
if (sstring[0] == 0 || (sstring[0] == 1 && sstring[1] == 0))
#endif
{
return format[0];
}
#pragma tabsize 4
new
formatPos = 0,
sstringPos = 0,
paramPos = 2,
paramCount = numargs(),
delim = ' ';
while (sstring[sstringPos] && sstring[sstringPos] <= ' ')
{
sstringPos++;
}
while (paramPos < paramCount && sstring[sstringPos])
{
switch (format[formatPos++])
{
case '\0':
{
return 0;
}
case 'i', 'd':
{
new
neg = 1,
num = 0,
ch = sstring[sstringPos];
if (ch == '-')
{
neg = -1;
ch = sstring[++sstringPos];
}
do
{
sstringPos++;
if ('0' <= ch <= '9')
{
num = (num * 10) + (ch - '0');
}
else
{
return -1;
}
}
while ((ch = sstring[sstringPos]) > ' ' && ch != delim);
setarg(paramPos, 0, num * neg);
}
case 'h', 'x':
{
new
num = 0,
ch = sstring[sstringPos];
do
{
sstringPos++;
switch (ch)
{
case 'x', 'X':
{
num = 0;
continue;
}
case '0' .. '9':
{
num = (num << 4) | (ch - '0');
}
case 'a' .. 'f':
{
num = (num << 4) | (ch - ('a' - 10));
}
case 'A' .. 'F':
{
num = (num << 4) | (ch - ('A' - 10));
}
default:
{
return -1;
}
}
}
while ((ch = sstring[sstringPos]) > ' ' && ch != delim);
setarg(paramPos, 0, num);
}
case 'c':
{
setarg(paramPos, 0, sstring[sstringPos++]);
}
case 'f':
{
new changestr[16], changepos = 0, strpos = sstringPos;
while(changepos < 16 && sstring[strpos] && sstring[strpos] != delim)
{
changestr[changepos++] = sstring[strpos++];
}
changestr[changepos] = '\0';
setarg(paramPos,0,_:floatstr(changestr));
}
case 'p':
{
delim = format[formatPos++];
continue;
}
case '\'':
{
new
end = formatPos - 1,
ch;
while ((ch = format[++end]) && ch != '\'') {}
if (!ch)
{
return -1;
}
format[end] = '\0';
if ((ch = strfind(sstring, format[formatPos], false, sstringPos)) == -1)
{
if (format[end + 1])
{
return -1;
}
return 0;
}
format[end] = '\'';
sstringPos = ch + (end - formatPos);
formatPos = end + 1;
}
case 'u':
{
new
end = sstringPos - 1,
id = 0,
bool:num = true,
ch;
while ((ch = sstring[++end]) && ch != delim)
{
if (num)
{
if ('0' <= ch <= '9')
{
id = (id * 10) + (ch - '0');
}
else
{
num = false;
}
}
}
if (num && IsPlayerConnected(id))
{
setarg(paramPos, 0, id);
}
else
{
#if !defined foreach
#define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
#define __SSCANF_FOREACH__
#endif
sstring[end] = '\0';
num = false;
new
name[MAX_PLAYER_NAME];
id = end - sstringPos;
foreach (Player, playerid)
{
GetPlayerName(playerid, name, sizeof (name));
if (!strcmp(name, sstring[sstringPos], true, id))
{
setarg(paramPos, 0, playerid);
num = true;
break;
}
}
if (!num)
{
setarg(paramPos, 0, INVALID_PLAYER_ID);
}
sstring[end] = ch;
#if defined __SSCANF_FOREACH__
#undef foreach
#undef __SSCANF_FOREACH__
#endif
}
sstringPos = end;
}
case 's', 'z':
{
new
i = 0,
ch;
if (format[formatPos])
{
while ((ch = sstring[sstringPos++]) && ch != delim)
{
setarg(paramPos, i++, ch);
}
if (!i)
{
return -1;
}
}
else
{
while ((ch = sstring[sstringPos++]))
{
setarg(paramPos, i++, ch);
}
}
sstringPos--;
setarg(paramPos, i, '\0');
}
default:
{
continue;
}
}
while (sstring[sstringPos] && sstring[sstringPos] != delim && sstring[sstringPos] > ' ')
{
sstringPos++;
}
while (sstring[sstringPos] && (sstring[sstringPos] == delim || sstring[sstringPos] <= ' '))
{
sstringPos++;
}
paramPos++;
}
do
{
if ((delim = format[formatPos++]) > ' ')
{
if (delim == '\'')
{
while ((delim = format[formatPos++]) && delim != '\'') {}
}
else if (delim != 'z')
{
return delim;
}
}
}
while (delim > ' ');
return 0;
}
Danke im Vorraus