Can someone help
#1

[/pawn]
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#include <a_mysql>

#define MYSQL_HOST "ip"
#define MYSQL_USER "username"
#define MYSQL_DB "database"
#define MYSQL_PASS "password"
#undef MAX_PLAYERS
#define MAX_PLAYERS 50 // Put this as low as you could!

enum pEnum
{
Name[MAX_PLAYER_NAME],
Password[32],
Admin,
Money,
};
new UserStats[MAX_PLAYERS][pEnum];

new AccountExists[MAX_PLAYERS];
new PlayerLogged[MAX_PLAYERS];

main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}

public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
ConnectMySQL();
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)
{
GetPlayerName(playerid, UserStats[playerid][Name], MAX_PLAYER_NAME);

if(CheckAccountExists(UserStats[playerid][Name])) AccountExists[playerid] = 1;
else AccountExists[playerid] = 0;
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
SavePlayer(playerid);

UserStats[playerid][Admin] = 0;
UserStats[playerid][Money] = 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[])
{
dcmd(register, 8, cmdtext);
dcmd(login, 5, cmdtext);
return 0;
}

dcmd_register(playerid, params[])
{
RegisterPlayer(playerid, params);
return 1;
}

dcmd_login(playerid, params[])
{
LoginPlayer(playerid, params);
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[])
{
return 1;
}

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

ConnectMySQL()
{
if(mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DB, MYSQL_PASS))
print("[MySQL] Connection to the MySQL Database was successfully!");

else
print("[MySQL] Could not connect to the MySQL Database!");
}

CheckMySQL()
{
if(mysql_ping() == -1)
mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DB, MYSQL_PASS);
}

CheckAccountExists(account[])
{
new string[128];
format(string, sizeof(string), "SELECT * FROM Users WHERE Name = '%s'", account);
mysql_query(string);

mysql_store_result();

new value;
value = mysql_num_rows();
mysql_free_result();
return value;
}

explode(const sSource[], aExplode[][], const sDelimiter[] = " ", iVertices = sizeof aExplode, iLength = sizeof aExplode[]) // Created by Westie
{
new
iNode,
iPointer,
iPrevious = -1,
iDelimiter = strlen(sDelimiter);

while(iNode < iVertices)
{
iPointer = strfind(sSource, sDelimiter, false, iPointer);

if(iPointer == -1)
{
strmid(aExplode[iNode], sSource, iPrevious, strlen(sSource), iLength);
break;
}
else
{
strmid(aExplode[iNode], sSource, iPrevious, iPointer, iLength);
}

iPrevious = (iPointer += iDelimiter);
++iNode;
}
return iPrevious;
}

RegisterPlayer(playerid, password[])
{
if(AccountExists[playerid])
return SendClientMessage(playerid, COLOR_RED, "[ACCOUNT] You're already registered!");

if(PlayerLogged[playerid])
return SendClientMessage(playerid, COLOR_RED, "[ACCOUNT] You're already logged in!");

if(strlen(password) < 3 || strlen(password) >= 32)
return SendClientMessage(playerid, COLOR_RED, "[ACCOUNT] Your password is too short or too long!");

CheckMySQL();

new string[128];
format(string, sizeof(string), "INSERT INTO Users (Name,Password) VALUES ('%s','%s')", UserStats[playerid][Name], password);
mysql_query(string);

AccountExists[playerid] = 1;
SendClientMessage(playerid, COLOR_YELLOW, "[ACCOUNT] Your account has been created, please login now!");

LoginPlayer(playerid, password);
return 1;
}

LoginPlayer(playerid, password[])
{
if(!AccountExists[playerid])
return SendClientMessage(playerid, COLOR_RED, "[ACCOUNT] You're not registered!");

if(PlayerLogged[playerid])
return SendClientMessage(playerid, COLOR_RED, "[ACCOUNT] You're already logged in!");

if(strlen(password) < 3 || strlen(password) >= 32)
return SendClientMessage(playerid, COLOR_RED, "[ACCOUNT] Your password is too short or too long!");

CheckMySQL();

new string[128];
format(string, sizeof(string), "SELECT * FROM Users WHERE Name = '%s' AND Password = '%s'", UserStats[playerid][Name], password);
mysql_query(string);
mysql_store_result();

if(!mysql_num_rows())
return SendClientMessage(playerid, COLOR_RED, "[ACCOUNT] Incorrect password!");

new row[128]; // The length of 1 'row' total.
new field[4][32]; // [4] = Amount of fields, [24] = Max length of the bigest field.

mysql_fetch_row_format(row, "|");
explode(row, field, "|");
mysql_free_result();

// The field starts here with 1, because the field 'Name' = 0, and we already have the name in a variable.
format(UserStats[playerid][Password], 32, "%s", field[1]);
UserStats[playerid][Admin] = strval(field[2]);
UserStats[playerid][Money] = strval(field[3]);

GivePlayerMoney(playerid, UserStats[playerid][Money]);


format(string, sizeof(string), "[ACCOUNT] Welcome back %s, you are now logged in!", UserStats[playerid][Name]);
SendClientMessage(playerid, COLOR_YELLOW, string);

PlayerLogged[playerid] = 1;
return 1;
}

SavePlayer(playerid)
{
if(!PlayerLogged[playerid])
return 0;

UserStats[playerid][Money] = GetPlayerMoney(playerid);


CheckMySQL();

new string[256];
format(string, sizeof(string), "UPDATE Users SET Password='%s',Admin='%d',Money='%d' WHERE Name='%s'", UserStats[playerid][Password], UserStats[playerid][Admin], UserStats[playerid][Money], UserStats[playerid][Name]);
mysql_query(string);
return 1;
}
[pawn]
C:\Users\Charles\Desktop\SAMP\gamemodes\bare.pwn(1 01) : error 017: undefined symbol "dcmd"
C:\Users\Charles\Desktop\SAMP\gamemodes\bare.pwn(1 02) : error 017: undefined symbol "dcmd"
C:\Users\Charles\Desktop\SAMP\gamemodes\bare.pwn(1 17) : error 010: invalid function or declaration
C:\Users\Charles\Desktop\SAMP\gamemodes\bare.pwn(3 94) : warning 203: symbol is never used: "LoginPlayer"
C:\Users\Charles\Desktop\SAMP\gamemodes\bare.pwn(3 94) : warning 203: symbol is never used: "RegisterPlayer"
C:\Users\Charles\Desktop\SAMP\gamemodes\bare.pwn(3 94) : warning 203: symbol is never used: "dcmd_login"
C:\Users\Charles\Desktop\SAMP\gamemodes\bare.pwn(3 94) : warning 203: symbol is never used: "dcmd_register"
C:\Users\Charles\Desktop\SAMP\gamemodes\bare.pwn(3 94) : warning 203: symbol is never used: "explode"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Reply


Messages In This Thread
Can someone help - by Notorious29 - 25.02.2011, 19:28
Re: Can someone help - by Mean - 25.02.2011, 19:37
Re: Can someone help - by Notorious29 - 25.02.2011, 19:40
Re: Can someone help - by Notorious29 - 25.02.2011, 19:49
Re: Can someone help - by Mean - 25.02.2011, 19:58
Re: Can someone help - by Notorious29 - 25.02.2011, 20:15
Re: Can someone help - by Mean - 25.02.2011, 20:20

Forum Jump:


Users browsing this thread: 1 Guest(s)