// Enum's die genutzt werden //
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
enum UserData
{
Username[MAX_PLAYER_NAME+1],
Geld,
Float:Leben,
Admin,
LastLogin[11],
bool:Logged,
LoginDataCacheID
}
// New's //
new mycon;
new User[MAX_PLAYERS][UserData];
// Farb definitionen //
#define Rot 0xFF0000FF
#define Gelb 0xFFFF00FF
#define Grün 0x00FF00FF
#define Blau 0x0000FFFF
#define Weis 0xFFFFFFFF
// New Definitionen //
#undef MAX_PLAYERS
#define MAX_PLAYERS 100
forward LoadPlayerDataSequence(playerid, l_step);
forward KickPlayer(playerid);
forward onCountryDetect(playerid, ip[]);
main()
{
print("\n----------------------------------");
print("New San Fierro by Shøxx");
print("----------------------------------\n");
}
public OnGameModeInit()
{
mycon = mysql_connect("127.0.0.1","root","samp","");
SetGameModeText("New San Fierro");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
DisableInteriorEnterExits();
AddStaticVehicle(411,2020.5170,1351.2760,9.7570,270.8903,125,125); // Start
//Fahrschule San Fierro
AddStaticVehicleEx(405,-2081.0000000,-83.8000000,35.2000000,0.0000000,255,255,15); //Sentinel
AddStaticVehicleEx(405,-2076.8999000,-83.8000000,35.2000000,0.0000000,255,255,15); //Sentinel
AddStaticVehicleEx(405,-2085.1999500,-83.9000000,35.2000000,0.0000000,255,255,15); //Sentinel
AddStaticVehicleEx(560,-2072.8000500,-84.0000000,35.0000000,0.0000000,255,255,15); //Sultan
AddStaticVehicleEx(560,-2064.3000500,-84.1000000,35.0000000,0.0000000,255,255,15); //Sultan
AddStaticVehicleEx(560,-2068.5000000,-84.0000000,35.0000000,0.0000000,255,255,15); //Sultan
AddStaticVehicleEx(403,-2081.0000000,-100.0000000,35.9000000,270.0000000,255,255,15); //Linerunner
AddStaticVehicleEx(450,-2091.3999000,-100.1000000,35.8000000,270.2500000,255,255,15); //Trailer 2
AddStaticVehicleEx(593,-2086.8999000,-114.5000000,35.9000000,181.2490000,255,255,15); //Dodo
AddStaticVehicleEx(593,-2068.3999000,-114.0000000,35.9000000,181.2470000,255,255,15); //Dodo
AddStaticVehicleEx(487,-2027.8000500,-189.0000000,35.6000000,270.0000000,255,255,15); //Maverick
AddStaticVehicleEx(487,-2028.0999800,-215.8999900,35.6000000,270.0000000,255,255,15); //Maverick
CreateObject(1215,-2091.6999500,-80.4000000,34.7000000,0.0000000,0.0000000,0.0000000); //object(bollardlight) (1)
CreateObject(1215,-2087.6001000,-80.4000000,34.7000000,0.0000000,0.0000000,0.0000000); //object(bollardlight) (2)
CreateObject(1215,-2083.3000500,-80.4000000,34.7000000,0.0000000,0.0000000,0.0000000); //object(bollardlight) (3)
CreateObject(1215,-2079.1999500,-80.4000000,34.7000000,0.0000000,0.0000000,2.0000000); //object(bollardlight) (4)
CreateObject(1215,-2074.8000500,-80.4000000,34.7000000,0.0000000,0.0000000,2.0000000); //object(bollardlight) (5)
CreateObject(1215,-2070.6999500,-80.4000000,34.7000000,0.0000000,0.0000000,2.0000000); //object(bollardlight) (6)
CreateObject(1215,-2066.3999000,-80.4000000,34.7000000,0.0000000,0.0000000,2.0000000); //object(bollardlight) (7)
CreateObject(1215,-2062.3000500,-80.4000000,34.7000000,0.0000000,0.0000000,2.0000000); //object(bollardlight) (8)
CreateObject(3934,-2027.4000200,-189.1000100,34.4000000,0.0000000,0.0000000,359.5000000); //object(helipad01) (1)
CreateObject(3934,-2027.5000000,-215.8000000,34.4000000,0.0000000,0.0000000,0.0000000); //object(helipad01) (2)
public OnGameModeExit()
{
mysql_close();
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnPlayerConnect(playerid)
{
GetPlayerName(playerid,User[playerid][Username],MAX_PLAYER_NAME);
new query[60 + MAX_PLAYER_NAME];
mysql_format(mycon, query, sizeof(query), "SELECT * FROM `User` WHERE `Name` = '%s'",User[playerid][Username]);
mysql_function_query(mycon, query, true, "LoadPlayerDataSequence","dd",playerid,1);
new szPlayerIP[16], iNumIP;
GetPlayerIp(playerid, szPlayerIP, sizeof(szPlayerIP));
iNumIP = IpToInteger(szPlayerIP);
mysql_format(mycon, query, true, "SELECT `country_code`, `country_name` FROM `ip2c` WHERE \"%d\" BETWEEN `begin_ip_num` AND `end_ip_num` LIMIT 1", iNumIP);
mysql_function_query(mycon, query, true, "onCountryDetect", "ds", playerid, szPlayerIP);
new pName[MAX_PLAYER_NAME];
new string[48];
GetPlayerName(playerid, pName, sizeof(pName));
format(string, sizeof(string), "[Join] %s hat den Server betreten.", pName);
SendClientMessageToAll(Grün, string);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(User[playerid][Logged])
{
SavePlayerData(playerid);
}
//ResetPlayerVariables(playerid);
new pName[MAX_PLAYER_NAME];
new string[56];
GetPlayerName(playerid, pName, sizeof(pName));
switch(reason)
{
case 0: format(string, sizeof(string), "[Leave] %s hat hat die Verbindung verloren. (Netzwerk Timeout)", pName);
case 1: format(string, sizeof(string), "[Leave] %s hat den Server verlassen.", pName);
case 2: format(string, sizeof(string), "[Leave] %s musste den Server verlassen. (Kick/ban)", pName);
}
SendClientMessageToAll(Rot, string);
return 1;
public OnPlayerSpawn(playerid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
RemoveBuildingForPlayer(playerid, 11372, -2076.4375, -107.9297, 36.9688, 0.25);
RemoveBuildingForPlayer(playerid, 11099, -2056.9922, -184.5469, 34.4141, 0.25);
RemoveBuildingForPlayer(playerid, 11014, -2076.4375, -107.9297, 36.9688, 0.25);
RemoveBuildingForPlayer(playerid, 4516, -141.3359, 468.6484, 12.9141, 0.25);
RemoveBuildingForPlayer(playerid, 4517, -193.8281, 269.5078, 12.8906, 0.25);
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[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 0;
}
if(!strcmp(strget(cmdtext, 0), "/givemoney"))
{
if(!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, Rot, "Du bist kein Admin und kannst diesen Befehl deswegen nicht ausführen.");
}
else
{
new spielerid = strval(strget(cmdtext, 1));
new geld = strval(strget(cmdtext, 2));
GivePlayerMoney(spielerid, geld);
return 1;
}
}
return 0;
}
// Allgemeiner OCMD Bereich //
// Allgemeiner OCMD Bereich Ende //
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)
{
if(!User[playerid][Logged]) return 0;
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)
{
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
if(!success) //If the password was incorrect
{
printf("FAILED RCON LOGIN BY IP %s USING PASSWORD %s",ip, password);
new pip[16];
for(new i=0; i<MAX_PLAYERS; i++) //Loop through all players
{
GetPlayerIp(i, pip, sizeof(pip));
if(!strcmp(ip, pip, true)) //If a player's IP is the IP that failed the login
{
SendClientMessage(i, Rot, "Wrong Password. Bye!"); //Send a message
Ban(i); //They are now banned.
}
}
}
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[])
{
switch(dialogid)
{
case DIALOG_REGISTER:
{
if(!response)
{
SendClientMessage(playerid,0xFF0000FF,"Bitte benutzen Sie /q, um das Spiel zu beenden!");
SetTimerEx("KickPlayer",250,0,"i",playerid);
return 1;
}
new InputLength = strlen(inputtext);
if(InputLength < 3 || InputLength > 25)
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "{00FF00}[Passwort Eingabe - Registrierung]","{FFFFFF}Bitte geben Sie Ihr gewünschtes Passwort ein!\n{FF0000}Bitte zwischen 3 & 25 Zeichen!","Register","Abbrechen");
return 1;
}
new query[128+MAX_PLAYER_NAME], day, month, year;
getdate(day, month, year);
format(query, sizeof(query),"%i/%i/%i",day,month,year);
mysql_format(mycon, query, sizeof(query), "INSERT INTO `User` (`Name`, `Passwort`, `Geld`, `Leben`, `Admin`, `LastLogin`) VALUES('%s','%s',0,100.0,0,'%s')", User[playerid][Username], inputtext, query);
mysql_function_query(mycon, query, false, "", "");
User[playerid][Logged] = true;
SpawnPlayer(playerid);
return 1;
}
case DIALOG_LOGIN:
{
if(!response)
{
SendClientMessage(playerid,0xFF0000FF,"Bitte benutzen Sie /q, um das Spiel zu beenden!");
SetTimerEx("KickPlayer",250,0,"i",playerid);
return 1;
}
new InputLength = strlen(inputtext);
if(InputLength < 3 || InputLength > 25)
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "{00FF00}[Passwort Eingabe - Loginsequenz]","{FFFFFF}Bitte geben Sie Ihr Passwort ein!\n{FF0000}Es hat mindestens 3 Zeichen!","Login","Abbrechen");
return 1;
}
cache_set_active(User[playerid][LoginDataCacheID]);
new UserPassword[64];
cache_get_field_content(0, "Passwort", UserPassword);
if(strcmp(UserPassword, inputtext) == 0) {
User[playerid][Geld] = cache_get_field_content_int(0,"Geld",1);
User[playerid][Leben] = cache_get_field_content_float(0,"Leben",1);
User[playerid][Admin] = cache_get_field_content_int(0, "Admin",1);
cache_get_field_content(0,"LastLogin",User[playerid][LastLogin],1);
User[playerid][Logged] = true;
SpawnPlayer(playerid);
cache_delete(User[playerid][LoginDataCacheID]);
User[playerid][LoginDataCacheID] = 0;
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "{00FF00}[Passwort Eingabe - Loginsequenz]","{FFFFFF}Bitte geben Sie Ihr richtiges Passwort ein!\n{FF0000}Die vorherige Eingabe war falsch!","Login","Abbrechen");
return 1;
}
return 1;
}
}
return 1;
}
public LoadPlayerDataSequence(playerid, l_step)
{
if(User[playerid][LoginDataCacheID] <= 0)
User[playerid][LoginDataCacheID] = cache_save();
User[playerid][Geld] = cache_get_field_content_int(0,"Geld");
new Rows, Fields;
cache_get_data(Rows, Fields);
if(Rows)
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "{00FF00}[Passwort Eingabe - Loginsequenz]","{FFFFFF}Bitte geben Sie Ihr Passwort ein!","Login","Abbrechen");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "{00FF00}[Passwort eingabe - Registrierung]","{FFFFFF}Bitte geben Sie Ihr gewünschtes Passwort ein!","Register","Abbrechen");
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
public KickPlayer(playerid)
return Kick(playerid);
public onCountryDetect(playerid, ip[])
{
if(IsPlayerConnected(playerid)) {
new rows, fields, szPlayerName[MAX_PLAYER_NAME];
cache_get_data(rows, fields);
new country_name[30], country_code[30];
#define FIELD_COUNTRYNAME 0
#define FIELD_COUNTRYCODE 1
cache_get_row(0, FIELD_COUNTRYNAME, country_name);
cache_get_row(0, FIELD_COUNTRYCODE, country_code);
GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
printf("Player %s (ID: %d, IP: %s, Country: %s, CountryCode: %s)", szPlayerName, playerid, country_name, country_code);
}
return 1;
}
stock SavePlayerData(playerid)
{
new query[100 + MAX_PLAYER_NAME];
mysql_format(mycon,query, sizeof(query), "UPDATE `User` SET `Geld` = %i WHERE `Name` = %i ",User[playerid][Geld],User[playerid][Username]);
mysql_function_query(mycon,query,false,"","");
mysql_format(mycon,query, sizeof(query),"UPDATE `User` SET `Leben` = %.1f WHERE `Name` = '%s' ",User[playerid][Leben],User[playerid][Username]);
mysql_function_query(mycon,query,false,"","");
mysql_format(mycon,query, sizeof(query),"UPDATE `User` SET `Admin` = %i WHERE `Name` = %i ",User[playerid][Admin],User[playerid][Username]);
mysql_function_query(mycon,query,false,"","");
new day,month,year; getdate(day,month,year);
format(User[playerid][LastLogin],11,"%i/%i/%i",day,month,year);
mysql_format(mycon,query, sizeof(query),"UPDATE `User` SET `LastLogin` = '%s' WHERE `Name` = '%s' ",User[playerid][LastLogin],User[playerid][Username]);
mysql_function_query(mycon,query,false,"","");
return 1;
}
/*stock ResetPlayerVariables(playerid)
{
User[playerid][Geld] = 0;
User[playerid][Leben] = 0.0;
strdel(User[playerid][Username],0,MAX_PLAYER_NAME+1);
strdel(User[playerid][LastLogin],0,1);
User[playerid][Logged] = false;
User[playerid][LoginDataCacheID] = 0;
return 1;
}*/
stock IpToInteger(ip[])
{
new ipPart[4][4], iPart, cPos, idx;
for(new a = strlen(ip);idx < a;idx++) {
if(ip[idx] == '.') {
strmid(ipPart[iPart], ip, cPos, idx, 4);
cPos = idx + 1;
iPart++;
}
}
strmid(ipPart[3], ip, cPos, idx, 4);
return (strval(ipPart[0]) << 24) | (strval(ipPart[1]) << 16) | (strval(ipPart[2]) << 8) | strval(ipPart[3]);
}
stock strget(strx[], pos, search = ' ') {
new arg, ret[128], idxx;
for (new i = 0; i < strlen(strx); i++) {
if(strx[i] == search || i == strlen(strx) || strx[i + 1] == 10) {
arg++;
if (arg == pos + 1){
ret[i-idxx] = EOS;
return ret;
} else if (arg == pos)
idxx= i+1;
}
else if (arg == pos)
ret[i - idxx] = strx[i];
}
return ret;
}