09.07.2012, 09:15
Hello, i have some bugs with my script. the first bug is that after registering you cant then login the next time you join the server, i have had to make it to u dont get kicked so i can test my scripts. the other bug is that when you spawn you freeze for some time.
pawn Код:
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*\
|| ||
|| Started Creating on the 9th July 2012 By Brennan Butler (brennan9723@hotmail.com). ||
|| This is a script for DC(Drift Crew) ||
|| Owner of the server - Situation[DC_O] Dylan Vd Heuvel ||
|| ||
|| ||
\*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
//==========================[INCLUDES]=================================//
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#include <YSI\y_ini>
#include <streamer>
#include <foreach>
native WP_Hash(buffer[],len,const str[]);
//=======================[OTHER]======================================//
forward loadaccount_user(playerid, name[], value[]);
native IsValidVehicle(vehicleid);
stock PlayerName(playerid)
{
new pName[24];
GetPlayerName(playerid,pName,24);
return pName;
}
stock ProxDetector(Float:radi, playerid, string[],color)
{
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
foreach(Player,i) {
if(IsPlayerInRangeOfPoint(i,radi,x,y,z)) {
SendClientMessage(i,color,string);
}
}
}
stock FlipCar(carid)
{
new Float:FCX, Float:FCY, Float:FCZ, Float:FCA;
GetVehiclePos(carid, FCX, FCY, FCZ);
GetVehicleZAngle(carid, FCA);
SetVehiclePos(carid, FCX, FCY, (FCZ+1.0));
SetVehicleZAngle(carid, FCA);
}
stock GivePlayerScore(playerid, ammount)
{
new currentscore;
currentscore = GetPlayerScore(playerid);
SetPlayerScore(playerid, currentscore + ammount);
}
//=======================[DEFINES]=======================================//
#define IsPlayerSpawned(%1) Spawned[%1]
#define VERSION "Crrent Version: 0.01 In devolpment"
#define dregister 2011
#define dlogin 2012
#define UserPath "DC/Users/%s.ini"
#define DIALOG_CRIMES 5
#define COLOR_ORANGE 0xFF8000FF
#define COLOR_GRAD1 0xB4B5B7FF
#define COLOR_GRAD2 0xBFC0C2FF
#define COLOR_GRAD3 0xCBCCCEFF
#define COLOR_GRAD4 0xD8D8D8FF
#define COLOR_GRAD5 0xE3E3E3FF
#define COLOR_GRAD6 0xF0F0F0FF
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_BLUE1 0x0066FFFF
#define COLOR_RED 0xAA3333AA
#define COLOR_RED2 0xFF0000FF
#define COLOR_REALRED 0xFF0606FF
#define COLOR_LIGHTRED 0xFF6347AA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_LIGHTGREEN 0x9ACD32AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_VIP 0xC93CCE00
#define COLOR_YELLOW2 0xF5DEB3AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_FADE1 0xE6E6E6E6
#define COLOR_FADE2 0xC8C8C8C8
#define COLOR_FADE3 0xAAAAAAAA
#define COLOR_FADE4 0x8C8C8C8C
#define COLOR_FADE5 0x6E6E6E6E
#define COLOR_PURPLE 0xC2A2DAAA
#define COLOR_PINK 0xFF66FFAA
#define COLOR_DBLUE 0x2641FEAA
#define COLOR_BLACK 0x000000AA
#define COLOR_MAROON #800000
stock Path(playerid)
{
new str[128],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(str,sizeof(str),UserPath,name);
return str;
}
//=============================[DRIFTER DEFINES]===============================//
#define DRIFTER 1
#define COLOR_DRIFTER COLOR_LIGHTBLUE
new gTeam[MAX_PLAYERS];
enum PInfo
{
Ppassword[24],
Pscore,
Pmoney,
Padmin,
Preg
}
new PlayerInfo[MAX_PLAYERS][PInfo];
main()
{
print("\n----------------------------------");
print(" Drift crew 0.3e server");
print("----------------------------------\n");
}
public OnGameModeInit()
{
SetGameModeText("Drifting");
UsePlayerPedAnims();
AddPlayerClass(0,-2228.5110,2326.6282,7.5469,134.5635,0,0,0,0,0,0);
AddPlayerClass(1,-2228.5110,2326.6282,7.5469,134.5635,0,0,0,0,0,0);
AddPlayerClass(2,-2228.5110,2326.6282,7.5469,134.5635,0,0,0,0,0,0);
AddPlayerClass(3,-2228.5110,2326.6282,7.5469,134.5635,0,0,0,0,0,0);
AddPlayerClass(4,-2228.5110,2326.6282,7.5469,134.5635,0,0,0,0,0,0);
AddPlayerClass(5,-2228.5110,2326.6282,7.5469,134.5635,0,0,0,0,0,0);
AddPlayerClass(6,-2228.5110,2326.6282,7.5469,134.5635,0,0,0,0,0,0);
AddPlayerClass(7,-2228.5110,2326.6282,7.5469,134.5635,0,0,0,0,0,0);
AddPlayerClass(8,-2228.5110,2326.6282,7.5469,134.5635,0,0,0,0,0,0);
AddPlayerClass(9,-2228.5110,2326.6282,7.5469,134.5635,0,0,0,0,0,0);
AddPlayerClass(10,-2228.5110,2326.6282,7.5469,134.5635,0,0,0,0,0,0);
AddPlayerClass(11,-2228.5110,2326.6282,7.5469,134.5635,0,0,0,0,0,0);
AddPlayerClass(12,-2228.5110,2326.6282,7.5469,134.5635,0,0,0,0,0,0);
AddPlayerClass(13,-2228.5110,2326.6282,7.5469,134.5635,0,0,0,0,0,0);
AddPlayerClass(14,-2228.5110,2326.6282,7.5469,134.5635,0,0,0,0,0,0);
AddPlayerClass(15,-2228.5110,2326.6282,7.5469,134.5635,0,0,0,0,0,0);
AddPlayerClass(16,-2228.5110,2326.6282,7.5469,134.5635,0,0,0,0,0,0);
AddPlayerClass(17,-2228.5110,2326.6282,7.5469,134.5635,0,0,0,0,0,0);
AddPlayerClass(18,-2228.5110,2326.6282,7.5469,134.5635,0,0,0,0,0,0);
AddPlayerClass(19,-2228.5110,2326.6282,7.5469,134.5635,0,0,0,0,0,0);
AddPlayerClass(20,-2228.5110,2326.6282,7.5469,134.5635,0,0,0,0,0,0);
AddPlayerClass(21,-2237.7124,2353.5083,4.9804,134.5635,0,0,0,0,0,0);
AddPlayerClass(22,-2237.7124,2353.5083,4.9804,134.5635,0,0,0,0,0,0);
AddPlayerClass(23,-2237.7124,2353.5083,4.9804,134.5635,0,0,0,0,0,0);
AddPlayerClass(24,-2237.7124,2353.5083,4.9804,134.5635,0,0,0,0,0,0);
AddPlayerClass(26,-2237.7124,2353.5083,4.9804,134.5635,0,0,0,0,0,0);
AddPlayerClass(27,-2237.7124,2353.5083,4.9804,134.5635,0,0,0,0,0,0);
AddPlayerClass(28,-2237.7124,2353.5083,4.9804,134.5635,0,0,0,0,0,0);
AddPlayerClass(29,-2237.7124,2353.5083,4.9804,134.5635,0,0,0,0,0,0);
AddPlayerClass(30,-2237.7124,2353.5083,4.9804,134.5635,0,0,0,0,0,0);
AddPlayerClass(31,-2237.7124,2353.5083,4.9804,134.5635,0,0,0,0,0,0);
AddPlayerClass(32,-2237.7124,2353.5083,4.9804,134.5635,0,0,0,0,0,0);
AddPlayerClass(33,-2237.7124,2353.5083,4.9804,134.5635,0,0,0,0,0,0);
AddPlayerClass(34,-2237.7124,2353.5083,4.9804,134.5635,0,0,0,0,0,0);
AddPlayerClass(35,-2237.7124,2353.5083,4.9804,134.5635,0,0,0,0,0,0);
AddPlayerClass(36,-2237.7124,2353.5083,4.9804,134.5635,0,0,0,0,0,0);
AddPlayerClass(37,-2237.7124,2353.5083,4.9804,134.5635,0,0,0,0,0,0);
AddPlayerClass(38,-2237.7124,2353.5083,4.9804,134.5635,0,0,0,0,0,0);
AddPlayerClass(39,-2237.7124,2353.5083,4.9804,134.5635,0,0,0,0,0,0);
AddPlayerClass(40,-2237.7124,2353.5083,4.9804,134.5635,0,0,0,0,0,0);
AddPlayerClass(41,-2237.7124,2353.5083,4.9804,134.5635,0,0,0,0,0,0);
AddPlayerClass(42,-2237.7124,2353.5083,4.9804,134.5635,0,0,0,0,0,0);
AddPlayerClass(43,-2237.7124,2353.5083,4.9804,134.5635,0,0,0,0,0,0);
AddPlayerClass(45,-2237.7124,2353.5083,4.9804,134.5635,0,0,0,0,0,0);
AddPlayerClass(46,-2237.7124,2353.5083,4.9804,134.5635,0,0,0,0,0,0);
return 1;
}
public OnGameModeExit()
{
return 1;
}
public loadaccount_user(playerid, name[], value[])
{
INI_String("Ppassword", PlayerInfo[playerid][Ppassword],24);
INI_Int("Padmin",PlayerInfo[playerid][Padmin]);
INI_Int("Pmoney",PlayerInfo[playerid][Pmoney]);
INI_Int("Pscore",PlayerInfo[playerid][Pscore]);
INI_Int("Preg",PlayerInfo[playerid][Preg]);
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1220.0737,-6.3703,1001.3281);
SetPlayerInterior(playerid,2);
SetPlayerFacingAngle(playerid,92.3402);
SetPlayerCameraPos(playerid,1214.3527,-6.4071,1001.3290);
SetPlayerCameraLookAt(playerid, 1220.0737,-6.3703,1000.3281);
switch(classid)
{
case 0..23:
{
GameTextForPlayer(playerid, "~g~Drifter", 5000, 6);
gTeam[playerid] = DRIFTER;
}
case 24..46:
{
GameTextForPlayer(playerid, "~r~Drifter", 5000, 6);
gTeam[playerid] = DRIFTER;
}
}
return 1;
}
public OnPlayerConnect(playerid)
{
SendDeathMessage(playerid, INVALID_PLAYER_ID, 200);
new string[128];
format(string, sizeof(string), "%s Has joined the server!", PlayerName(playerid), PlayerName(playerid));
SendClientMessageToAll(COLOR_GREY, string);
new name[MAX_PLAYER_NAME]; //Making a new variable called 'name'. name[MAX_PLAYER_NAME] is created so we can use it to get player's name.
GetPlayerName(playerid,name,sizeof(name)); //Get player's name
if(fexist(Path(playerid))) /* Check if the connected user is registered or not. fexist stands for file exist. So if file exist in the files(Path(playerid)),*/
{// then
INI_ParseFile(Path(playerid),"loadaccount_user", .bExtra = true, .extra = playerid); //Will load user's data using INI_Parsefile.
ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_PASSWORD,"Login","Welcome back. This account is registered. \nInsert your password to login to your account","Login","Quit");/*A dialog with input style will appear so you can insert your password to login.*/
}
else //If the connected user is not registered,
{//then we will 'force' him to register :)
ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.","Register","Quit");
return 1;
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
SendDeathMessage(INVALID_PLAYER_ID, playerid, 201);
new string[64], name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
switch(reason)
{
case 0: format(string,sizeof string,"%s left the server. (Timeout/Crash)",name);
case 1: format(string,sizeof string,"%s left the server. (Leaving)",name);
case 2: format(string,sizeof string,"%s left the server. (Kicked/Banned)",name);
}
SendClientMessageToAll(COLOR_GREY,string);
if(fexist(Path(playerid)))
{
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file,"Player's Data");
INI_WriteInt(file,"Padmin",PlayerInfo[playerid][Padmin]);
INI_WriteInt(file,"Pmoney",GetPlayerMoney(playerid));
INI_WriteInt(file,"Pscore",GetPlayerScore(playerid));
INI_Close(file);
return 1;
}
return 1;
}
public OnPlayerSpawn(playerid)
{
SetPlayerInterior(playerid, 0);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
SendDeathMessage(killerid, playerid, reason);
SetPlayerInterior(playerid, 0);
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 1;
}
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)
{
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 == dregister)
{
if(!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext))
{
ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.\nPlease enter the password!","Register","Quit");
return 1;
}
new hashpass[129];
WP_Hash(hashpass,sizeof(hashpass),inputtext);
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file,"Player's Data");
INI_WriteString(file,"Ppassword",hashpass);
INI_WriteInt(file,"Padmin",0);
INI_WriteInt(file,"Pmoney",0);
INI_WriteInt(file,"Pscore",0);
INI_WriteInt(file,"Preg",1);
INI_Close(file);
SendClientMessage(playerid,-1,"You have been successfully registered");
}
}
if(dialogid == dlogin)
{
if(response)
{
new hashpass[129];
WP_Hash(hashpass,sizeof(hashpass),inputtext);
if(!strcmp(hashpass,PlayerInfo[playerid][Ppassword]))
{
INI_ParseFile(Path(playerid),"loadaccount_user",.bExtra = true, .extra = playerid);
SetPlayerScore(playerid,PlayerInfo[playerid][Pscore]);
GivePlayerMoney(playerid,PlayerInfo[playerid][Pmoney]);
SendClientMessage(playerid,-1,"Welcome back! You have successfully logged in");
}
else
{
ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_PASSWORD,"Login","Welcome back. This account is registered. \nInsert your password to login to your account.\nIncorrect password!","Login","Quit");//We will tell to them that they've entered an incorrect password
return 1;
}
}
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}