How to load giftcode from 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: How to load giftcode from mysql! (
/showthread.php?tid=489656)
How to load giftcode from mysql! -
nguyenquynh - 23.01.2014
Код:
CMD:giftcode(playerid, params[])
{
if(PlayerInfo[playerid][pLevel] == 3)
{
ShowPlayerDialog(playerid, DIALOG_NHAPKEY, DIALOG_STYLE_INPUT, "He thong nhap code","Vui long nhap ma giftcode duoi day:","Thuc hien","Huy bo");
}
return 1;
}
Код:
case DANGNHAP_KEY:
{
new titlestring[64];
new string[512];
for(new i;i < rows;i++)
{
new
szMAK[129],
szResult[129],
szkey[129];
if(strcmp(szResult, GetPlayerNameExt(extraid), true) != 0)
{
//g_mysql_AccountAuthCheck(extraid);
return 1;
}
cache_get_field_content(i, "KEY1", szResult, MainPipeline);
GetPVarString(extraid, "Passkey", szkey, sizeof(szkey));
PlayerInfo[extraid][pCash] += 200000;
PlayerInfo[extraid][pLevel] += 2;
ShowPlayerDialog(extraid, DIALOG_SHOP, DIALOG_STYLE_LIST,"Cua hang OOC","The Kinh Ngiem [5 - Diem] - Gia 10 Coin\nThe Exp X2 (1 the - 20 Coin)\nThe Giam Han Che Vu Khi (1 the - 5 Coin)\nShop Token{FFFFFF}\nShop Toys\nVIP\nPhuong tien","Mua","Thoat");
format(szMAK, sizeof(szMAK), szkey);
if((isnull(szMAK)) || (isnull(szResult)) || (strcmp(szMAK, szResult) != 0))
{
format(titlestring, sizeof(titlestring), "He Thong Nhap Gift Key - %s", GetPlayerNameEx(extraid));
format(string, sizeof(string), "{FFFFFF}Nhap ma gift code duoi day de duoc nhan qua - %s", GetPlayerNameEx(extraid));
ShowPlayerDialog(extraid,DIALOG_NHAPKEY,DIALOG_STYLE_INPUT,titlestring,string,"Thuc hien","Thoat");
if(++gPlayerLogTries[extraid] == 2)
{
SendClientMessage(extraid, COLOR_RED, "[He Thong]: Giftcode nay khong ton tai.");
}
return 1;
}
DeletePVar(extraid, "Passkey");
break;
}
return 1;
}
Код:
if(dialogid == DIALOG_NHAPKEY)
{
if(!isnull(inputtext) && strlen(inputtext) < 120)
{
SetPVarString(playerid, "Passkey", inputtext);
g_mysql_GiftKey(playerid);
}
}
Код:
stock g_mysql_GiftKey(playerid)
{
new string[500];
format(string, sizeof(string), "SELECT * FROM `giftcode` WHERE `id` = '%d'", GetPlayerSQLId(playerid));
mysql_function_query(MainPipeline, string, true, "OnQueryFinish", "iii", DANGNHAP_KEY, playerid, g_arrQueryHandle{playerid});
return 1;
}
![](http://i4.upanh.com/2014/0122/20//58584775.samp007.png)
It dosen't work when player enter the code in dialog....