SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   SA-MP Scripting help me pls... (https://forum.sa-mp.com/showthread.php?t=672622)

Razvan234512312 21/02/2020 02:33 PM

SA-MP Scripting help me pls...
 
C:\Users\kfune\Desktop\GM de Ash\gamemodes\gm.pwn(6) : error 001: expected token: ";", but found "-"
C:\Users\kfune\Desktop\GM de Ash\gamemodes\gm.pwn(40) : warning 213: tag mismatch
C:\Users\kfune\Desktop\GM de Ash\gamemodes\gm.pwn(43) : warning 217: loose indentation
C:\Users\kfune\Desktop\GM de Ash\gamemodes\gm.pwn(59) : error 017: undefined symbol "qQuery"
C:\Users\kfune\Desktop\GM de Ash\gamemodes\gm.pwn(59) : warning 215: expression has no effect
C:\Users\kfune\Desktop\GM de Ash\gamemodes\gm.pwn(59) : error 001: expected token: ";", but found "]"
C:\Users\kfune\Desktop\GM de Ash\gamemodes\gm.pwn(59) : error 029: invalid expression, assumed zero
C:\Users\kfune\Desktop\GM de Ash\gamemodes\gm.pwn(59) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


5 Errors.
[Finished in 0.2s]



/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include <a_samp>

#include <a_mysql>


new SQL - -1, qQuery[256]

#define function%0(%1) forward %0(%1); public %0(%1)

enum pInfo {
pSQLID,
pName[MAX_PLAYER_NAME],
pPassword[32],
pEmail[32],
pGender

}
new PlayerInfo[MAX_PLAYERS][pInfo];

enum {
// Register
DIALOG_REGISTER,
DIALOG_EMAIL,
DIALOG_GENDER,

// Login
DIALOG_LOGIN
}

#define Ash "#1"

main() { print("Gamemode-ul este in curs de procesare..."); }





public OnGameModeInit()
{
SQL = mysql_connect("localhost", "root", "ash", "");

// Don't use these lines if it's a filterscript
SetGameModeText(Ash);
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
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) {
qQuery[0] = EOS;
mysql_format(SQL, qQuery, sizeof(qQuery), "SELECT * FROM `users` WHERE `Name`='%s' LIMIT 1", GetName(playerid));
mysql_tquery(SQL, qQuery, "CheckAccount", "1", playerid);
return 1;

}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
switch(dialogid) {

}
return 1;
}

function CheckAccount(playerid) {
switch(cache_num_rows()) {
case 0: ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Scrie o Parola pentru a te putea inregistra:", "Select", "Cancel");
case 1: ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Scrie Parola pentru a te putea loga:", "Select", "Cancel");
}
return 1;
}

stock GetName(playerid) {
new playerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
return playerName;
}

Razvan234512312 21/02/2020 02:36 PM

Re: SA-MP Scripting help me pls...
 
I'm a beginner scriptwriter (help me pls xd)

Kwarde 21/02/2020 02:43 PM

Re: SA-MP Scripting help me pls...
 
You're missing semicolons here and there (;), and
new SQL - -1, qQuery[256]
: it should be 'new SQL = -1'

I suggest you to start learning scripting basics first before trying to create things.
Check my signature (click on the link you shouldn't click on) for a link to the PAWN guide. Check out other basics for PAWN here: https://wiki.sa-mp.com/wiki/Scripting_Basics
For super-basics, try searching on the internet.

Alternatively, if you don't want to use semicoloms you can use option -;- to disable the need of semicoloms. Example:
pawn Code:
#pragma option -;-

main()
{
    print("This is a valid code")
    return 1
}
However I don't recommend it if you're a beginner. If you're a pro, even then I don't recommend it


EDIT:
I'm using ZeeX's compiler. Not sure if the default compiler has this option.

Razvan234512312 21/02/2020 03:24 PM

Re: SA-MP Scripting help me pls...
 
Thx Very Much

Razvan234512312 21/02/2020 03:32 PM

Re: SA-MP Scripting help me pls...
 
I have other error 1

C:\Users\kfune\Desktop\GM de Ash\gamemodes\gm.pwn(12) : error 001: expected token: ";", but found "enum"


//////////////////////////////////////

enum pInfo {
pSQLID,
pName[MAX_PLAYER_NAME],
pPassword[32],
pEmail[32],
pGender

}

SiaReyes 21/02/2020 04:57 PM

Re: SA-MP Scripting help me pls...
 
Code:

new SQL, qQuery[256] ;

Razvan234512312 21/02/2020 05:00 PM

Re: SA-MP Scripting help me pls...
 
Thank you very much <3

Razvan234512312 21/02/2020 08:54 PM

Re: SA-MP Scripting help me pls...
 
I have error xd

C:\Users\kfune\Desktop\GM de Ash\gamemodes\gm.pwn(41) : warning 213: tag mismatch
C:\Users\kfune\Desktop\GM de Ash\gamemodes\gm.pwn(44) : warning 217: loose indentation
C:\Users\kfune\Desktop\GM de Ash\gamemodes\gm.pwn(61) : warning 213: tag mismatch
C:\Users\kfune\Desktop\GM de Ash\gamemodes\gm.pwn(62) : warning 217: loose indentation
C:\Users\kfune\Desktop\GM de Ash\gamemodes\gm.pwn(62) : warning 213: tag mismatch
C:\Users\kfune\Desktop\GM de Ash\gamemodes\gm.pwn(72) : error 029: invalid expression, assumed zero
C:\Users\kfune\Desktop\GM de Ash\gamemodes\gm.pwn(72) : warning 215: expression has no effect
C:\Users\kfune\Desktop\GM de Ash\gamemodes\gm.pwn(72) : error 001: expected token: ";", but found ")"
C:\Users\kfune\Desktop\GM de Ash\gamemodes\gm.pwn(72) : error 029: invalid expression, assumed zero
C:\Users\kfune\Desktop\GM de Ash\gamemodes\gm.pwn(72) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
[Finished in 0.2s]






////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <a_samp>

#include <a_mysql>


new SQL = -1, qQuery[256] ;



#define function%0(%1) forward %0(%1); public %0(%1)

enum pInfo {
pSQLID,
pName[MAX_PLAYER_NAME],
pPassword[32],
pEmail[32],
pGender
}
new PlayerInfo[MAX_PLAYERS][pInfo];

enum {
// Register
DIALOG_REGISTER,
DIALOG_EMAIL,
DIALOG_GENDER,

// Login
DIALOG_LOGIN
}

#define Ash "#1"

main() { print("Gamemode-ul este in curs de procesare..."); }





public OnGameModeInit()
{
SQL = mysql_connect("localhost", "root", "ash", "");

// Don't use these lines if it's a filterscript
SetGameModeText(Ash);
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
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) {
qQuery[0] = EOS;
mysql_format(SQL, qQuery, sizeof(qQuery), "SELECT * FROM `users` WHERE `Name`='%s' LIMIT 1", GetName(playerid));
mysql_tquery(SQL, qQuery, "CheckAccount", "1", playerid);
return 1;

}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
switch(dialogid) {
case DIALOG_REGISTER: {
if(!response)
return Kick(playerid);

if(strlen(inputtext)) < 6 || strlen(inputtext) > 32)
return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Scrie o parola pentru a te putea inregistra (minim 6 caracter / maxim 32):", "Select", "Cancel");

qQuery[0] = EOS;
mysql_format(SQL, qQuery, sizeof(qQuery), "INSERT INTO `users` (`Name`, `Password`) VALUES ('%s', '%s')", GetName(playerid), inputtext);
mysql_tquery(SQL, qQuery, "insertAccount", "i" playerid);
}
}
return 1;
}
function inserAccount(playerid) {
PlayerInfo[playerid][pSQLID] = cache_insert_id();
printf("%s s-a inregistrat #%d.", GetName(playerid), PlayerInfo[playerid][pSQLID]);
return 1;
}

function CheckAccount(playerid) {
switch(cache_num_rows()) {
case 0: ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Scrie o parola pentru a te putea inregistra (minim 6 caracter / maxim 32):", "Select", "Cancel");
case 1: ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Scrie Parola pentru a te putea loga:", "Select", "Cancel");
}
return 1;
}

stock GetName(playerid) {
new playerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
return playerName;
}

Razvan234512312 21/02/2020 08:56 PM

Re: SA-MP Scripting help me pls...
 
Sorry for multiple posts I'm a beginner

d3Pedro 21/02/2020 10:25 PM

Re: SA-MP Scripting help me pls...
 
pawn Code:
mysql_tquery(SQL, qQuery, "insertAccount", "i", playerid);
You forgot a comma at this line

and this
pawn Code:
if(strlen(inputtext)) < 6 || strlen(inputtext) > 32)
should be:
pawn Code:
if(strlen(inputtext) < 6 || strlen(inputtext) > 32)



This
pawn Code:
mysql_tquery(SQL, qQuery, "insertAccount", "i", playerid); // the callback isn't the same of what you've defined

pawn Code:
function inserAccount(playerid) {
PlayerInfo[playerid][pSQLID] = cache_insert_id();
printf("%s s-a inregistrat #%d.", GetName(playerid), PlayerInfo[playerid][pSQLID]);
return 1;
}

You may fix it.


All times are GMT. The time now is 01:20 PM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.