Location Problem
#1

Hello, I'm Livar. I'm kinda new to PAWNO scripting so bare with me guys, my problem is:

I am currently trying to make a Roleplay script set in LS, here is what I have currently done (not really good but yeh)

Код:
// Project Los Santos Life Roleplay by Livar Shekhani!
// NOTE: This server was created for EDUCATIONAL purposes only!

// Script Includes
#include <a_samp>
#include <dini>
#include <zcmd>
#include <dudb>
#include <dutils>
#include <streamer>
#include <sscanf2>
#include <foreach>

// Script Defines
#define USERS_FOLDER "Users/%s.ini"
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_RED 0xAA3333AA
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_PINK 0xFF66FFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_DARKRED 0x660000AA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_BRIGHTRED 0xFF0000AA
#define COLOR_INDIGO 0x4B00B0AA
#define COLOR_VIOLET 0x9955DEEE
#define COLOR_LIGHTRED 0xFF99AADD
#define COLOR_SEAGREEN 0x00EEADDF
#define COLOR_GRAYWHITE 0xEEEEFFC4
#define COLOR_LIGHTNEUTRALBLUE 0xabcdef66
#define COLOR_GREENISHGOLD 0xCCFFDD56
#define COLOR_LIGHTBLUEGREEN 0x0FFDD349
#define COLOR_NEUTRALBLUE 0xABCDEF01
#define COLOR_LIGHTCYAN 0xAAFFCC33
#define COLOR_LEMON 0xDDDD2357
#define COLOR_MEDIUMBLUE 0x63AFF00A
#define COLOR_NEUTRAL 0xABCDEF97
#define COLOR_BLACK 0x00000000
#define COLOR_NEUTRALGREEN 0x81CFAB00
#define COLOR_DARKGREEN 0x12900BBF
#define COLOR_LIGHTGREEN 0x24FF0AB9
#define COLOR_DARKBLUE 0x300FFAAB
#define COLOR_BLUEGREEN 0x46BBAA00
#define COLOR_PINK 0xFF66FFAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_DARKRED 0x660000AA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_PURPLE 0x800080AA
#define COLOR_GRAD1 0xB4B5B7FF
#define COLOR_GRAD2 0xBFC0C2FF
#define COLOR_RED1 0xFF0000AA
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BROWN 0x993300AA
#define COLOR_CYAN 0x99FFFFAA
#define COLOR_TAN 0xFFFFCCAA
#define COLOR_PINK 0xFF66FFAA
#define COLOR_KHAKI 0x999900AA
#define COLOR_LIME 0x99FF00AA
#define COLOR_SYSTEM 0xEFEFF7AA
#define COLOR_GRAD2 0xBFC0C2FF
#define COLOR_GRAD4 0xD8D8D8FF
#define COLOR_GRAD6 0xF0F0F0FF
#define COLOR_GRAD2 0xBFC0C2FF
#define COLOR_GRAD3 0xCBCCCEFF
#define COLOR_GRAD5 0xE3E3E3FF
#define COLOR_GRAD1 0xB4B5B7FF

// Ignores Script Errors
#pragma unused ret_memcpy

// Player Enum
enum pInfo
{
	pPassword,
    pAdmin,
    pMoney,
    pLevel,
    pSkin,
    pFaction,
    pFamily,
    pVehicle,
	pHouse,
	pLocation,
	pHealth,
	pArmour,
}

// Creates a new Variable for the enum
new PlayerInfo[MAX_PLAYERS][pInfo];
new gPlayerLogged[MAX_PLAYERS];

// Script Initiate on SAMP-SERVER.exe
main()
{
	print("\n----------------------------------");
	print(" Project Los Santos Life Roleplay");
	print("----------------------------------\n");
}

// Script GameModeInitiate
public OnGameModeInit()
{
	// Normal script crap!
	SetGameModeText("LSL-RP v0.1a (10th June)");
    DisableInteriorEnterExits();
    ShowPlayerMarkers(0);
	AddPlayerClass(0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
	
	// DMV Mapping!
	CreateObject(12957, 2420.2565917969, -1677.3601074219, 13.591270446777, 0, 0, 0);
	CreateObject(1328, 2490.2590332031, -1684.8607177734, 13.023999214172, 0, 0, 0);
	CreateObject(1328, 2509.0336914063, -1682.3243408203, 13.06201171875, 0, 0, 0);
	CreateObject(2114, 2531.3718261719, -1667.2886962891, 14.314910888672, 0, 0, 0);
	CreateObject(9618, 2498.796875, -1681.6447753906, 18.08959197998, 0, 0, 270.99645996094);
	CreateObject(11015, 2058.7407226563, -1897.6586914063, 14.442544937134, 0, 0, 0.70068359375);
	CreateObject(10401, 2060.2541503906, -1908.9079589844, 14.838247299194, 0, 0, 45.390014648438);
	CreateObject(970, 2051.7214355469, -1922.7426757813, 13.098356246948, 0, 0, 0);
	CreateObject(970, 2055.9223632813, -1922.7553710938, 13.098356246948, 0, 0, 0);
	CreateObject(970, 2060.0817871094, -1922.8024902344, 13.098356246948, 0, 0, 0);
	CreateObject(970, 2064.248046875, -1922.7414550781, 13.098356246948, 0, 0, 0);
	CreateObject(970, 2068.3354492188, -1922.7071533203, 13.098356246948, 0, 0, 0);
	CreateObject(970, 2069.7795410156, -1922.6339111328, 13.098356246948, 0, 0, 0);
	CreateObject(970, 2071.7395019531, -1920.5668945313, 13.098356246948, 0, 0, 271.20495605469);
	CreateObject(970, 2069.6655273438, -1906.2243652344, 13.098356246948, 0, 0, 179.39306640625);
	CreateObject(970, 2071.7570800781, -1908.2952880859, 13.098356246948, 0, 0, 90.800231933594);
	CreateObject(970, 2071.7145996094, -1919.4630126953, 13.098356246948, 0, 0, 90.825012207031);
	CreateObject(966, 2071.6755371094, -1917.3288574219, 12.596874237061, 0, 0, 269.92504882813);
	CreateObject(968, 2071.6945800781, -1917.4572753906, 13.471876144409, 1, 26, 89.995086669922);
	CreateObject(1358, 2070.4301757813, -1900.3294677734, 13.757347106934, 0, 0, 271.17498779297);
	
	return 1;
}

public OnGameModeExit()
{
	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)
{
	// Set's gPlayerLogged to 0 = means not logged in (yet)
    gPlayerLogged[playerid] = 0;
    
    // Creates a new variable for the Players name!
    new name[MAX_PLAYER_NAME], file[256];
    
    // Get's the player name using a_samp's function
    GetPlayerName(playerid, name, sizeof(name));
    
    format(file, sizeof(file), USERS_FOLDER, name);
    
    // Look's into the "Users/" folder to check if the user exists or not!
    if (!dini_Exists(file))
    {
		// Sends the player a dialog with a message telling them to enter a desired password for their new account
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Welcome to LSL-RP", "It seems you do not have an account, please enter your desired password below", "Register", "Leave");
    }
    
    // If the account exists in the "Users/" folder, ask them to enter their password!
    if(fexist(file))
    {
		// Sends the player a dialog with a message telling them to enter their previously selected password for their account
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Welcome to LSL-RP", "It seems you do have an account, please enter your password below", "Login", "Leave");
    }
    
    // Calls for our function which checks to see if the User has a roleplay formatted name (Forename_Lastname)
    if(!IsRolePlayName(playerid))
	{
        SendClientMessage(playerid, COLOR_RED, "[SYSTEM]: %s has been auto-kicked for not having a roleplay formatted name!");
        Kick(playerid);
        return 1;
    }
    
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	// Creates a variable for the Users name
    new name[MAX_PLAYER_NAME], file[256];
    
    // Retrives the users name and put's it in our variable
    GetPlayerName(playerid, name, sizeof(name));
    
    // Defines the "USERS_FOLDER" and stores our name in it!
    format(file, sizeof(file), USERS_FOLDER, name);
    
    // Checks to see if the player is logged in, if so, set their variables and add their stats!
    if(gPlayerLogged[playerid] == 1)
    {
		// Set some variables for our player when logged out
		new Float:x, Float:y, Float:z;
		GetPlayerPos(playerid, x, y, z);
		
		// Sets variables in their .ini files
        dini_IntSet(file, "Password", PlayerInfo[playerid][pPassword]);
        dini_IntSet(file, "Admin", PlayerInfo[playerid][pAdmin]);
        dini_IntSet(file, "Money", PlayerInfo[playerid][pMoney]);
        dini_IntSet(file, "Level", PlayerInfo[playerid][pLevel]);
        dini_IntSet(file, "Skin", PlayerInfo[playerid][pSkin]);
        dini_IntSet(file, "Faction", PlayerInfo[playerid][pFaction]);
        dini_IntSet(file, "Family", PlayerInfo[playerid][pFamily]);
        dini_IntSet(file, "Vehicle", PlayerInfo[playerid][pVehicle]);
        dini_IntSet(file, "House", PlayerInfo[playerid][pHouse]);
        dini_IntSet(file, "Location", GetPlayerPos(playerid, x, y, z));
        dini_IntSet(file, "Health", GetPlayerHealth(playerid));
        dini_IntSet(file, "Armour", GetPlayerArmour(playerid));
    }
    
    // Sets the PlayerLogged variable to 0 = logged out!
    gPlayerLogged[playerid] = 0;
    
	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;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/mycommand", cmdtext, true, 10) == 0)
	{
		// Do something here
		return 1;
	}
	return 0;
}

// Script Commands
CMD:pm(playerid, params[])
{
    new str[256], str2[256], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
    if(sscanf(params, "us", id, str2))
    {
        SendClientMessage(playerid, 0xFF0000FF, "Usage: /pm <id> <message>");
        return 1;
    }
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: Player not connected to the server!");
    if(playerid == id) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You cannot PM yourself!");
    {
        GetPlayerName(playerid, Name1, sizeof(Name1));
        GetPlayerName(id, Name2, sizeof(Name2));
        format(str, sizeof(str), "PM To %s(ID %d): %s", Name2, id, str2);
        SendClientMessage(playerid, 0xFF0000FF, str);
        format(str, sizeof(str), "PM From %s(ID %d): %s", Name1, playerid, str2);
        SendClientMessage(id, 0xFF0000FF, str);
    }
    return 1;
}

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[])
{
	// Dialog ID 1 (register dialog)
    if (dialogid == 1)
    {
		// Creates a variable for our player name
        new name[MAX_PLAYER_NAME], file[256], string[128];
        
        // Retrieves the players name
        GetPlayerName(playerid, name, sizeof(name));
        
        // Checks the "USERS_FOLDER" and creates a file with their name
        format(file, sizeof(file), USERS_FOLDER, name);
        
        // If their is no response, kick the player
        if(!response) return Kick(playerid);
        
        // If there is no string lengh, just returna  dialog telling them to register
        if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Welcome to LSL-RP", "It seems you do not have an account, please enter your desired password below", "Register", "Leave");

		// Creates the file named "%s" which is their users name ofc!
		dini_Create(file);
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "Admin", PlayerInfo[playerid][pAdmin] = 0);
        dini_IntSet(file, "Money", PlayerInfo[playerid][pMoney] = 500);
        dini_IntSet(file, "Level", PlayerInfo[playerid][pLevel] = 1);
        dini_IntSet(file, "Skin", PlayerInfo[playerid][pSkin] = 299);
        dini_IntSet(file, "Faction", PlayerInfo[playerid][pFaction] = 0);
        dini_IntSet(file, "Family", PlayerInfo[playerid][pFamily] = 0);
        dini_IntSet(file, "Vehicle", PlayerInfo[playerid][pVehicle] = 0);
        dini_IntSet(file, "House", PlayerInfo[playerid][pHouse] = 0);
        dini_IntSet(file, "Location" PlayerInfo[playerid][pLocation] = 0);
        format(string, 128, "[SYSTEM]: Welcome to Los Santos Life Roleplay %s!", name);
        SendClientMessage(playerid, COLOR_GREEN, string);
        
        // Set the PlayerLogged to 1 = logged in!
        gPlayerLogged[playerid] = 1;
    }
    
    // Dialog ID 2 (logging in)
    if (dialogid == 2)
    {
		// Creates a new variable for our users name
        new name[MAX_PLAYER_NAME], file[256], string[128];
        
        // Retrieves our users name and stores it in our variable
        GetPlayerName(playerid, name, sizeof(name));
        
        // Looks into our USERS_FOLDER for the "%s" name (username ofc)
        format(file, sizeof(file), USERS_FOLDER, name);
        
        // If their is no response, kick the player!
        if(!response) return Kick(playerid);
        
        // If the string length is 0 (means nothing entered) return the dialog telling them that to re-log in
        if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Welcome to LSL-RP", "It seems you do have an account, please enter your password below", "Login", "Leave");

		// Creates a new variable called "tmp" (temporary) just to check if the entered password is the correct one!
		new tmp;
        tmp = dini_Int(file, "Password");
        
        // If the entered password does not match the one in the .ini file, tell them the password is wrong
        if(udb_hash(inputtext) != tmp)
		{
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Invalid Password", "Please re-enter the correct password below", "Login", "Leave");
        }
        
        // If the password does match, set some shit!
        else
        {
			// Set the PlayerLogged to 1 = logged in
            gPlayerLogged[playerid] = 1;
            
            // Sets the PlayersAdmin Level to the one in their file!
            PlayerInfo[playerid][pAdmin] = dini_Int(file, "AdminLevel");
            
            // Set the Player Level to the one in their file!
            SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
            
            // Give the player the money that matches the one in their file!
            GivePlayerMoney(playerid, dini_Int(file, "Money"));
            
            // Set the Player Skin to the one that is in their file!
            SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
            
            // Spawn the player in their last found position!
            SetPlayerPos(playerid, PlayerInfo[playerid][pLocation]);
            
            // Set the Player Health to theirs!
            SetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
            
            // Set the Player Armour to theirs!
            SetPlayerArmour(playerid, PlayerInfo[playerid][pArmour]);
            
            SendClientMessage(playerid, COLOR_GREEN, "[SYSTEM]: You have succesfully logged in!");
        }
    }
    
	return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
	return 1;
}

// Checks to see if the Users trying to enter has a roleplay formatted name!
stock IsRolePlayName(playerid, bool:alphaonly = true)
{
    new trpn[MAX_PLAYER_NAME];
    if(GetPlayerName(playerid,trpn,sizeof(trpn))) {
        new strd = strfind(trpn, "_", false);

        if(strfind(trpn,"_",false,strd+1) == -1) {
            if(strd > 0) {
                if(trpn[strd-1] && trpn[strd+1]) {
                    if(alphaonly) {
                        for(new a = 0, l = strlen(trpn); a < l; a++) {
                            switch(trpn[a]) {
                                case '0' .. '9': return 0;

                                    case 'a' .. 'z': continue;
                                    case 'A' .. 'Z': continue;
                                                  
                                    case '_': continue;

                                    default: return 0;
                            }
                        }
                    }
                    return 1;
                }
            }
        }
    }
    return 0;
}
My current problem is the registering location, the problem is kind of when you register I wan't them to spawn at these co-ordinates:
Код:
AddPlayerClass(0,2048.0845,-1913.4015,13.5469,272.1132,0,0,0,0,0,0);
But I'm really not sure how to actually put it in my script, take a look at my OnDialog call back to see my registering.

Really would like some help, cheers!
Reply
#2

Under OnPlayerSpawn, add this:

pawn Код:
SetPlayerPos(playerid, 2048.0845,-1913.4015,13.5469);
Reply
#3

Quote:
Originally Posted by ricardo178
Посмотреть сообщение
Under OnPlayerSpawn, add this:

pawn Код:
SetPlayerPos(playerid, 2048.0845,-1913.4015,13.5469);
So you wan't me to remove my SetPlayerPos, SetPlayerHealth, SetPlayerSkin under the OnDialogResponse eh?
Reply
#4

Quote:
Originally Posted by Livar
Посмотреть сообщение
So you wan't me to remove my SetPlayerPos, SetPlayerHealth, SetPlayerSkin under the OnDialogResponse eh?
No.. I want you, or better, you want, to add it under OnPlayerSpawn.. xD
Reply
#5

Right, I've got another problem now:

Код:
// Project Los Santos Life Roleplay by Livar Shekhani!
// NOTE: This server was created for EDUCATIONAL purposes only!

// Script Includes
#include <a_samp>
#include <dini>
#include <zcmd>
#include <dudb>
#include <dutils>
#include <streamer>
#include <sscanf2>
#include <foreach>

// Script Defines
#define USERS_FOLDER "Users/%s.ini"
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_RED 0xAA3333AA
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_PINK 0xFF66FFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_DARKRED 0x660000AA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_BRIGHTRED 0xFF0000AA
#define COLOR_INDIGO 0x4B00B0AA
#define COLOR_VIOLET 0x9955DEEE
#define COLOR_LIGHTRED 0xFF99AADD
#define COLOR_SEAGREEN 0x00EEADDF
#define COLOR_GRAYWHITE 0xEEEEFFC4
#define COLOR_LIGHTNEUTRALBLUE 0xabcdef66
#define COLOR_GREENISHGOLD 0xCCFFDD56
#define COLOR_LIGHTBLUEGREEN 0x0FFDD349
#define COLOR_NEUTRALBLUE 0xABCDEF01
#define COLOR_LIGHTCYAN 0xAAFFCC33
#define COLOR_LEMON 0xDDDD2357
#define COLOR_MEDIUMBLUE 0x63AFF00A
#define COLOR_NEUTRAL 0xABCDEF97
#define COLOR_BLACK 0x00000000
#define COLOR_NEUTRALGREEN 0x81CFAB00
#define COLOR_DARKGREEN 0x12900BBF
#define COLOR_LIGHTGREEN 0x24FF0AB9
#define COLOR_DARKBLUE 0x300FFAAB
#define COLOR_BLUEGREEN 0x46BBAA00
#define COLOR_PINK 0xFF66FFAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_DARKRED 0x660000AA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_PURPLE 0x800080AA
#define COLOR_GRAD1 0xB4B5B7FF
#define COLOR_GRAD2 0xBFC0C2FF
#define COLOR_RED1 0xFF0000AA
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BROWN 0x993300AA
#define COLOR_CYAN 0x99FFFFAA
#define COLOR_TAN 0xFFFFCCAA
#define COLOR_PINK 0xFF66FFAA
#define COLOR_KHAKI 0x999900AA
#define COLOR_LIME 0x99FF00AA
#define COLOR_SYSTEM 0xEFEFF7AA
#define COLOR_GRAD2 0xBFC0C2FF
#define COLOR_GRAD4 0xD8D8D8FF
#define COLOR_GRAD6 0xF0F0F0FF
#define COLOR_GRAD2 0xBFC0C2FF
#define COLOR_GRAD3 0xCBCCCEFF
#define COLOR_GRAD5 0xE3E3E3FF
#define COLOR_GRAD1 0xB4B5B7FF

// Ignores Script Errors
#pragma unused ret_memcpy

// Player Enum
enum pInfo
{
	pPassword,
    pAdmin,
    pMoney,
    pLevel,
    pSkin,
    pFaction,
    pFamily,
    pVehicle,
	pHouse,
	pX,
	pY,
	pZ,
	pAngle,
	pInterior,
	pVirtualWorld,
	pHealth,
	pArmour,
}

// Creates a new Variable for the enum
new PlayerInfo[MAX_PLAYERS][pInfo];
new gPlayerLogged[MAX_PLAYERS];

// Script Initiate on SAMP-SERVER.exe
main()
{
	print("\n----------------------------------");
	print(" Project Los Santos Life Roleplay");
	print("----------------------------------\n");
}

// Script GameModeInitiate
public OnGameModeInit()
{
	// Normal script crap!
	SetGameModeText("LSL-RP v0.1a (10th June)");
    DisableInteriorEnterExits();
    ShowPlayerMarkers(0);
	
	// DMV Mapping!
	CreateObject(12957, 2420.2565917969, -1677.3601074219, 13.591270446777, 0, 0, 0);
	CreateObject(1328, 2490.2590332031, -1684.8607177734, 13.023999214172, 0, 0, 0);
	CreateObject(1328, 2509.0336914063, -1682.3243408203, 13.06201171875, 0, 0, 0);
	CreateObject(2114, 2531.3718261719, -1667.2886962891, 14.314910888672, 0, 0, 0);
	CreateObject(9618, 2498.796875, -1681.6447753906, 18.08959197998, 0, 0, 270.99645996094);
	CreateObject(11015, 2058.7407226563, -1897.6586914063, 14.442544937134, 0, 0, 0.70068359375);
	CreateObject(10401, 2060.2541503906, -1908.9079589844, 14.838247299194, 0, 0, 45.390014648438);
	CreateObject(970, 2051.7214355469, -1922.7426757813, 13.098356246948, 0, 0, 0);
	CreateObject(970, 2055.9223632813, -1922.7553710938, 13.098356246948, 0, 0, 0);
	CreateObject(970, 2060.0817871094, -1922.8024902344, 13.098356246948, 0, 0, 0);
	CreateObject(970, 2064.248046875, -1922.7414550781, 13.098356246948, 0, 0, 0);
	CreateObject(970, 2068.3354492188, -1922.7071533203, 13.098356246948, 0, 0, 0);
	CreateObject(970, 2069.7795410156, -1922.6339111328, 13.098356246948, 0, 0, 0);
	CreateObject(970, 2071.7395019531, -1920.5668945313, 13.098356246948, 0, 0, 271.20495605469);
	CreateObject(970, 2069.6655273438, -1906.2243652344, 13.098356246948, 0, 0, 179.39306640625);
	CreateObject(970, 2071.7570800781, -1908.2952880859, 13.098356246948, 0, 0, 90.800231933594);
	CreateObject(970, 2071.7145996094, -1919.4630126953, 13.098356246948, 0, 0, 90.825012207031);
	CreateObject(966, 2071.6755371094, -1917.3288574219, 12.596874237061, 0, 0, 269.92504882813);
	CreateObject(968, 2071.6945800781, -1917.4572753906, 13.471876144409, 1, 26, 89.995086669922);
	CreateObject(1358, 2070.4301757813, -1900.3294677734, 13.757347106934, 0, 0, 271.17498779297);
	
	return 1;
}

public OnGameModeExit()
{
	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)
{
	// Set's gPlayerLogged to 0 = means not logged in (yet)
    gPlayerLogged[playerid] = 0;
    
    // Creates a new variable for the Players name!
    new name[MAX_PLAYER_NAME], file[256];
    
    // Get's the player name using a_samp's function
    GetPlayerName(playerid, name, sizeof(name));
    
    format(file, sizeof(file), USERS_FOLDER, name);
    
    // Look's into the "Users/" folder to check if the user exists or not!
    if (!dini_Exists(file))
    {
		// Sends the player a dialog with a message telling them to enter a desired password for their new account
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Welcome to LSL-RP", "It seems you do not have an account, please enter your desired password below", "Register", "Leave");
    }
    
    // If the account exists in the "Users/" folder, ask them to enter their password!
    if(fexist(file))
    {
		// Sends the player a dialog with a message telling them to enter their previously selected password for their account
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Welcome to LSL-RP", "It seems you do have an account, please enter your password below", "Login", "Leave");
    }
    
    // Calls for our function which checks to see if the User has a roleplay formatted name (Forename_Lastname)
    if(!IsRolePlayName(playerid))
	{
        SendClientMessage(playerid, COLOR_RED, "[SYSTEM]: %s has been auto-kicked for not having a roleplay formatted name!");
        Kick(playerid);
        return 1;
    }
    
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	// Creates a variable for the Users name
    new name[MAX_PLAYER_NAME], file[256];
    
    // Retrives the users name and put's it in our variable
    GetPlayerName(playerid, name, sizeof(name));
    
    // Defines the "USERS_FOLDER" and stores our name in it!
    format(file, sizeof(file), USERS_FOLDER, name);
    
    // Checks to see if the player is logged in, if so, set their variables and add their stats!
    if(gPlayerLogged[playerid] == 1)
    {
        GetPlayerPos(playerid, PlayerInfo[playerid][pX], PlayerInfo[playerid][pY], PlayerInfo[playerid][pZ]);
        GetPlayerFacingAngle(playerid, PlayerInfo[playerid][pAngle]);
        
		// Sets variables in their .ini files
        dini_IntSet(file, "Password", PlayerInfo[playerid][pPassword]);
        dini_IntSet(file, "Admin", PlayerInfo[playerid][pAdmin]);
        dini_IntSet(file, "Money", PlayerInfo[playerid][pMoney]);
        dini_IntSet(file, "Level", PlayerInfo[playerid][pLevel]);
        dini_IntSet(file, "Skin", PlayerInfo[playerid][pSkin]);
        dini_IntSet(file, "Faction", PlayerInfo[playerid][pFaction]);
        dini_IntSet(file, "Family", PlayerInfo[playerid][pFamily]);
        dini_IntSet(file, "Vehicle", PlayerInfo[playerid][pVehicle]);
        dini_IntSet(file, "House", PlayerInfo[playerid][pHouse]);
        dini_IntSet(file, "X", PlayerInfo[playerid][pX]);
        dini_IntSet(file, "Y", PlayerInfo[playerid][pY]);
        dini_IntSet(file, "Z", PlayerInfo[playerid][pZ]);
        dini_IntSet(file, "Angle", PlayerInfo[playerid][pAngle]);
        dini_IntSet(file, "Interior", PlayerInfo[playerid][pInterior]);
        dini_IntSet(file, "VirtualWorld", PlayerInfo[playerid][pVirtualWorld]);
        dini_IntSet(file, "Health", GetPlayerHealth(playerid));
        dini_IntSet(file, "Armour", GetPlayerArmour(playerid));
    }
    
    // Sets the PlayerLogged variable to 0 = logged out!
    gPlayerLogged[playerid] = 0;
    
	return 1;
}

public OnPlayerSpawn(playerid)
{
    // Set the Player Level to the one in their file!
    SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);

    // Give the player the money that matches the one in their file!
    GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);

    // Set the Player Skin to the one that is in their file!
    SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);

    // Set the Player Health to theirs!
    SetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);

    // Set the Player Armour to theirs!
    SetPlayerArmour(playerid, PlayerInfo[playerid][pArmour]);
    
    // Spawn the player at their last position!
    SetPlayerPos(playerid, PlayerInfo[playerid][pX], PlayerInfo[playerid][pY], PlayerInfo[playerid][pZ]);
    SetPlayerFacingAngle(playerid, PlayerInfo[playerid][pAngle]);
    SetPlayerInterior(playerid, PlayerInfo[playerid][pInterior]);
    SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][pVirtualWorld]);
        
	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 1;
	}
	return 0;
}

// Script Commands
CMD:pm(playerid, params[])
{
    new str[256], str2[256], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
    if(sscanf(params, "us", id, str2))
    {
        SendClientMessage(playerid, 0xFF0000FF, "Usage: /pm <id> <message>");
        return 1;
    }
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: Player not connected to the server!");
    if(playerid == id) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You cannot PM yourself!");
    {
        GetPlayerName(playerid, Name1, sizeof(Name1));
        GetPlayerName(id, Name2, sizeof(Name2));
        format(str, sizeof(str), "PM To %s(ID %d): %s", Name2, id, str2);
        SendClientMessage(playerid, 0xFF0000FF, str);
        format(str, sizeof(str), "PM From %s(ID %d): %s", Name1, playerid, str2);
        SendClientMessage(id, 0xFF0000FF, str);
    }
    return 1;
}

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[])
{
	// Dialog ID 1 (register dialog)
    if (dialogid == 1)
    {
		// Creates a variable for our player name
        new name[MAX_PLAYER_NAME], file[256], string[128];
        
        // Retrieves the players name
        GetPlayerName(playerid, name, sizeof(name));
        
        // Checks the "USERS_FOLDER" and creates a file with their name
        format(file, sizeof(file), USERS_FOLDER, name);
        
        // If their is no response, kick the player
        if(!response) return Kick(playerid);
        
        // If there is no string lengh, just returna  dialog telling them to register
        if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Welcome to LSL-RP", "It seems you do not have an account, please enter your desired password below", "Register", "Leave");

		// Creates the file named "%s" which is their users name ofc!
		dini_Create(file);
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "Admin", PlayerInfo[playerid][pAdmin] = 0);
        dini_IntSet(file, "Money", PlayerInfo[playerid][pMoney] = 500);
        dini_IntSet(file, "Level", PlayerInfo[playerid][pLevel] = 1);
        dini_IntSet(file, "Skin", PlayerInfo[playerid][pSkin] = 299);
        dini_IntSet(file, "Faction", PlayerInfo[playerid][pFaction] = 0);
        dini_IntSet(file, "Family", PlayerInfo[playerid][pFamily] = 0);
        dini_IntSet(file, "Vehicle", PlayerInfo[playerid][pVehicle] = 0);
        dini_IntSet(file, "House", PlayerInfo[playerid][pHouse] = 0);
        dini_IntSet(file, "X", PlayerInfo[playerid][pX] = 2048.0845);
        dini_IntSet(file, "Y", PlayerInfo[playerid][pY] = -1913.4015);
        dini_IntSet(file, "Z", PlayerInfo[playerid][pZ] = 13.5469);
        dini_IntSet(file, "Angle", PlayerInfo[playerid][pAngle] = 0);
        dini_IntSet(file, "Interior", PlayerInfo[playerid][pInterior] = 0);
        dini_IntSet(file, "VirtualWorld", PlayerInfo[playerid][pVirtualWorld] = 0);
        format(string, 128, "[SYSTEM]: Welcome to Los Santos Life Roleplay %s!", name);
        SendClientMessage(playerid, COLOR_GREEN, string);
        
        // Set the PlayerLogged to 1 = logged in!
        gPlayerLogged[playerid] = 1;
    }
    
    // Dialog ID 2 (logging in)
    if (dialogid == 2)
    {
		// Creates a new variable for our users name
        new name[MAX_PLAYER_NAME], file[256], string[128];
        
        // Retrieves our users name and stores it in our variable
        GetPlayerName(playerid, name, sizeof(name));
        
        // Looks into our USERS_FOLDER for the "%s" name (username ofc)
        format(file, sizeof(file), USERS_FOLDER, name);
        
        // If their is no response, kick the player!
        if(!response) return Kick(playerid);
        
        // If the string length is 0 (means nothing entered) return the dialog telling them that to re-log in
        if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Welcome to LSL-RP", "It seems you do have an account, please enter your password below", "Login", "Leave");

		// Creates a new variable called "tmp" (temporary) just to check if the entered password is the correct one!
		new tmp;
        tmp = dini_Int(file, "Password");
        
        // If the entered password does not match the one in the .ini file, tell them the password is wrong
        if(udb_hash(inputtext) != tmp)
		{
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Invalid Password", "Please re-enter the correct password below", "Login", "Leave");
        }
        
        // If the password does match, set some shit!
        else
        {
			// Set the PlayerLogged to 1 = logged in
            gPlayerLogged[playerid] = 1;
            
            SendClientMessage(playerid, COLOR_GREEN, "[SYSTEM]: You have succesfully logged in!");
        }
    }
    
	return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
	return 1;
}

// Checks to see if the Users trying to enter has a roleplay formatted name!
stock IsRolePlayName(playerid, bool:alphaonly = true)
{
    new trpn[MAX_PLAYER_NAME];
    if(GetPlayerName(playerid,trpn,sizeof(trpn))) {
        new strd = strfind(trpn, "_", false);

        if(strfind(trpn,"_",false,strd+1) == -1) {
            if(strd > 0) {
                if(trpn[strd-1] && trpn[strd+1]) {
                    if(alphaonly) {
                        for(new a = 0, l = strlen(trpn); a < l; a++) {
                            switch(trpn[a]) {
                                case '0' .. '9': return 0;

                                    case 'a' .. 'z': continue;
                                    case 'A' .. 'Z': continue;
                                                  
                                    case '_': continue;

                                    default: return 0;
                            }
                        }
                    }
                    return 1;
                }
            }
        }
    }
    return 0;
}
My problem is, It doesn't actually spawn at the co-ords I've given it, if some experienced scripter could actually take their time and check this, please do!
Reply
#6

I didn't basically read it all, but the variables of the position coordinates and the facing angle should be saved as a float, so for pinfo enum., change your current one to this:
pawn Код:
enum pinfo
{
    pPassword,
    pAdmin,
    pMoney,
    pLevel,
    pSkin,
    pFaction,
    pFamily,
    pVehicle,
    pHouse,
    float: pX,
    float: pY,
    float: pZ,
    float: pAngle,
    pInterior,
    pVirtualWorld,
    pHealth,
    pArmour,
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)