minor question
#1

Greetings,
I am at the moment struggeling,
i have created the command "/savespos"
and i want it to save in my database,
I know i do not have the connection details included in the script yet, but that is not the problem,

The problem is the command prefix should be "Usage ; /savespos [Dname] [Dnote]"
If not including a [Dname] or a [Dnote] it should return with an error message these need to be filled in,
the only thing im struggeling with is the String, since i never used them before.
As of now i got this code:

Код:
#include <a_samp>
#include <a_mysql>
#include <zcmd>
#define FILTERSCRIPT
/* Dynamic playerspawnpoint Creator thing
Have to create dialog for the name
have to create note for the note in the database.
*/

	new query[256];
	new Dname[128];
	new Dnote[128];
	
public OnFilterScriptInit()
{
	print("\n------Sa:Mp(0.3Z)----------------------");
	print("---------spawnpoint----------------------");
	print("-------V1.0 By Yvoms--------------------\n");
	return 1;
}

COMMAND:Savespos(playerid, Params[])
{
	//if an administrator uses this command the prefix should be /savespos [Dname] [Dnote]
	//the Dname and the Dnote should be saved in the database along with the cords.
	new String0[128];//the Dname - should be stored in database as varchar
	new String1[128];//the Dnote - should be stored in database as varchar
	new Float:Pos[4];
	GetPlayerPos(playerid, Pos[0],Pos[1],Pos[2]);
	GetPlayerFacingAngle(playerid, Pos[3]);
	

	format(query,sizeof(query),"INSERT INTO `SavedPos` (Dname,DynX,DynY,DynZ,DynA,Dnote) VALUES ('%s','%d','%f','%f','%f','%f')",string1,Pos[0],Pos[1],Pos[2],Pos[3],string0);
	mysql_query(query);

	return 1;
}
Helping me with this would be a huge step ahead for me since i can see what i've done wrong,
also i will learn from this.
Im asking for your help if you know how to do this,
Kind regards.
Reply
#2

SSCANF do exactly what you need.

Take a look: https://sampforum.blast.hk/showthread.php?tid=280476

pawn Код:
CMD:mycmd(playerid,params[])
{
    new a, Float:b, c[15];
    if(sscanf(params,"dfs[15]",a,b,c))
        return SendClientMessage(playerid,-1,"Usage: /mycmd [INTEGER] [FLOAT] [STRING]");
   // The rest of your cmd...
   return 1;
}
Reply
#3

I don't get what you posted im sorry..
Reply
#4

Quote:
Originally Posted by yvoms
Посмотреть сообщение
I don't get what you posted im sorry..
Read this thread: https://sampforum.blast.hk/showthread.php?tid=280476

There is a detailed tutorial.
Reply
#5

I'd read that already, and i still dont get it,
All i want is ....
a command like this
Код:
CMD:Note(playerid, o)
{
		if(sscanf(params,"s")) return SendClientMessage(playerid,COLOR_DEEPPINK,"{f41e98}[Admin]{ffffff} usage: /note [Texttosaveintothedatabase]");


return 1;
}
How do i work this out...
Reply
#6

This not need sscanf, cause it's a simple unique string you want to use, so this is the way:

pawn Код:
CMD:note(playerid,params[])
{
    if(isnull(params)) // if params is an empty string
    {
        // do something.
    }

    return 1;
}
Reply
#7

... i don't mean that,
i want the TEXT behind the /note STORED in my database.
Reply


Forum Jump:


Users browsing this thread: