Saving names in MySQL - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Saving names in MySQL (
/showthread.php?tid=282538)
Saving names in MySQL -
Kingunit - 11.09.2011
Hello,
Currently I'm using numbers in MySQL. Example of a command:
pawn Код:
CMD:makeadmin(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,".:: You are not authorized to use this command ::.");
new id, lvl;
GetPlayerRame(id, str, 24);
if(sscanf(params, "ui", id, lvl)) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_DGREY"[CMD] / "#COL_SGREY"[PlayerID/PartOfName] [Level]");
else
{
PlayerInfo[id][Adminlevel] = lvl;
}
return 1;
}
// This will save the Adminlevel that I drop into the command (f ex. /makeadmin 0 1)
But now I wanna save words / names. Something like this:
pawn Код:
CMD:setword(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,".:: You are not authorized to use this command ::.");
new id, word;
GetPlayerRame(id, str, 24);
if(sscanf(params, "ui", id, word)) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_DGREY"[CMD] / "#COL_SGREY"[PlayerID/PartOfName] [Word]");
else
{
PlayerInfo[id][Word] = word;
}
return 1;
}
How can I get something like that working. So in the database it's like:
Word = Hello
__
Hope you will understand this since I had struggs with writing this.
Re: Saving names in MySQL -
Vince - 11.09.2011
Make sure that you have 'word' set as array in your enum (e.g. word[32]). Then use strcpy to copy the string into another string.
pawn Код:
stock strcpy(dest[], const source[], maxlength=sizeof dest)
{
return strcat((dest[0] = EOS, dest), source, maxlength);
}