Jump to content

[PAWN] Tutorial 16 - /invite, /accept & /uninvite


PresidenT AnaS
 Share

Recommended Posts

Hello this day we have work about:/invite, /accept & /uninvite

//Includes

#include <a_samp>
#include <ocmd>
#include <sscanf2>
#include <a_mysql>
 
 
//Farben
#define COLOR_RED 0xFF0000FF
#define COLOR_WHITE 0xFFFFFFFF
#define COLOR_BLUE 0x009BFFFF
#define COLOR_YELLOW 0xEBFF00FF
 
//Dialoge
#define DIALOG_TELEPORT 1
#define DIALOG_REGISTER 2
#define DIALOG_LOGIN 3
#define DIALOG_AUTOHAUS 4
 
//MySQL
#define db_host "127.0.0.1"
#define db_user "samp"
#define db_pass "mysqlpasswort"
#define db_db "samp"
 
 
//enums
enum playerInfo{
eingeloggt,
level,
db_id,
alevel,
fraktion,
rang,
spawnchange
}
 
enum buildingsEnum{
Float:b_x,
Float:b_y,
Float:b_z,
Float:b_ix,
Float:b_iy,
Float:b_iz,
b_interior,
b_shopname[15]
}
 
enum carEnum{
id_x,
model,
besitzer,
Float:c_x,
Float:c_y,
Float:c_z,
Float:c_r,
db_id
}
 
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
}
 
enum fraktEnum{
f_name[128],
Float:f_x,
Float:f_y,
Float:f_z,
Float:f_r,
f_inter,
f_world,
f_color
}
 
//Globale Variablen
new dbhandle;
new sInfo[MAX_PLAYERS][playerInfo];
new fInfo[][fraktEnum] = {
{"Zivilist", 0.0, 0.0, 0.0, 0.0, 0, 0, COLOR_WHITE},
{"LSPD", 295.2865,-55.4151,2.7772,293.463, 0, 0, COLOR_BLUE},
{"Taxi", 0.0, 0.0, 0.0, 0.0, 0, 0, COLOR_YELLOW}
 
};
new bInfo[][buildingsEnum] = {
{243.0825,-178.3224,1.5822,285.3642,-41.5576,1001.5156,1,"AMMUN1"},//Ammunation1
{212.1142,-202.1886,1.5781,372.4523,-133.5244,1001.4922,5,"FDPIZA"}//Pizza
};
new cInfo[50][carEnum];
new ahInfo[][autohausEnum] = {
{125.7242,-170.1469,1.2838,177.7335},//id: 0 1. autohaus
{189.8910,-263.3446,1.2829,180.6895}//id: 1 2. autohaus
};
new ahCars[][autohauscarEnum] = {
{560,118.5637,-153.0834,1.2834,186.6475,50000,0},
{411,106.3420,-158.7720,1.7527,257.3197,80000,0},
{400,204.8894,-265.4756,1.2866,354.1406,10000,1}
};
new sekunden_timer;
 
new autosOhneMotor[] = {509,510,481};
 
new Text:uhrzeitLabel;
 
//Forwards
forward OnUserCheck(playerid);
forward OnPasswordResponse(playerid);
forward carSavedToDB(carid);
forward OnPlayerCarsLoad(playerid);
forward sekunde();
forward unfreezePlayer(playerid);
 
main()
{
 
}
 
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
for(new i=0; i<sizeof(bInfo); i++)
{
CreatePickup(1239,1,bInfo[b_x],bInfo[b_y],bInfo[b_z]);
Create3DTextLabel("Zum Betreten /enter",COLOR_RED,bInfo[b_x],bInfo[b_y],bInfo[b_z],10,0,1);
}
 
//Autos erstellen
AddStaticVehicle(560,214.1196,-141.3710,1.3052,1.6804,-1,-1); //Sultan
 
//Autohäuser laden
for(new i=0; i<sizeof(ahCars); i++)
{
ahCars[id_x]=AddStaticVehicle(ahCars[model],ahCars[c_x],ahCars[c_y],ahCars[c_z],ahCars[c_r],-1,-1);
}
 
//Timer
sekunden_timer = SetTimer("sekunde",1000,true);
 
//Textdraws
uhrzeitLabel = TextDrawCreate(557.000000, 12.000000, "00:00");
TextDrawBackgroundColor(uhrzeitLabel, 255);
TextDrawFont(uhrzeitLabel, 3);
TextDrawLetterSize(uhrzeitLabel, 0.580000, 2.399999);
TextDrawColor(uhrzeitLabel, -1);
TextDrawSetOutline(uhrzeitLabel, 1);
TextDrawSetProportional(uhrzeitLabel, 1);
 
//MySQL
dbhandle = mysql_connect(db_host,db_user,db_db,db_pass);
return 1;
}
 
public OnGameModeExit()
{
mysql_close(dbhandle);
return 1;
}
 
public sekunde()
{
new string[128];
for(new i=0; i<MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i))continue;
if(!IsPlayerInAnyVehicle(i))continue;
format(string,sizeof(string),"%ikm/h", getPlayerSpeed(i));
GameTextForPlayer(i, string, 1000, 3);
}
 
new hour, minute, second;
gettime(hour, minute, second);
format(string,sizeof(string),"%02d:%02d",hour, minute);
TextDrawSetString(uhrzeitLabel, string);
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;
}
 

 

 
if(sInfo[playerid][eingeloggt]==0)return 1;
//Speichern level,money
new query[256];
format(query,sizeof(query),"UPDATE user SET level='%i',money='%i',alevel='%i',fraktion='%i,rang='%i',spawnchange='%i' WHERE id='%i'",sInfo[playerid][level],
GetPlayerMoney(playerid),sInfo[playerid][alevel],sInfo[playerid][fraktion],sInfo[playerid][rang],sInfo[playerid][spawnchange],sInfo,sInfo[playerid][db_id]);
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)
{
for(new i=0; i<sizeof(cInfo); i++)
{
if(cInfo[id_x]==0)continue;
if(cInfo[besitzer]!=sInfo[playerid][db_id])continue;
GetVehiclePos(cInfo[id_x],cInfo[c_x],cInfo[c_y],cInfo[c_z]);
GetVehicleZAngle(cInfo[id_x],cInfo[c_r]);
new query[256];
format(query,sizeof(query),"UPDATE autos SET x='%f',y='%f',z='%f',r='%f' WHERE id='%i'",cInfo[c_x],cInfo[c_y],cInfo[c_z],cInfo[c_r],cInfo[db_id]);
mysql_function_query(dbhandle,query,false,"","");
DestroyVehicle(cInfo[id_x]);
cInfo[id_x]=0;
}
savePlayer(playerid);
resetPlayer(playerid);
return 1;
}
 
Thanks ƒor your time .Good Bye#

 

Edited by Cdorsu
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.