Jump to content

Problema salvare bani


Kox
 Share

Recommended Posts

Buna ziua ma scuzati ca va deranjez cu asta banuiesc ca e minor dar nu stiu sincer si vreau sa invat.

 

Nume:Kox

Varsta:22
Problema:Am un event Hallowen Event totul ok pana iau bani dupa ce gasesc obiectul dar cand ies si intru iarasi nu se salveaza bani.
Tin sa precizez ca gamemode ruleaza pe Mysql cu baza de date.
Imagini:Nu
Cod sursa: 

public OnPlayerPickUpPickup(playerid, pickupid)
{
        if(pickupid == Pumpkin)
        {
                DestroyPickup(Pumpkin);

                new
                        string[256],
                        randmoney = 50000 + random(10000),
                        name[MAX_PLAYER_NAME],
                        Hour, Minute, Second;

                Winner = 1;
                GetPlayerName(playerid, name, sizeof(name));
                format(string, sizeof(string), "> Pumpkin was found by %s. His wish him congratulations!", name);
                SendClientMessageToAll(COLOR_MAUVE, string);
                gettime(Hour, Minute, Second);
                format(string, sizeof(string), "> A new pumpkin will be hidden in %d minutes.", Minutes-Minute+10);
                SendClientMessageToAll(COLOR_MAUVE, string);
                format(string, sizeof(string), "You won the sum of $%d", randmoney);
                SendClientMessage(playerid, 0x2C8522FF, string);
                GivePlayerMoney(playerid, randmoney);

Va multumesc

Link to comment
Share on other sites

Ce fel de gm ai?

 

 

 

 

 

 

 

 

 
 
 

uwv7vag.gifCand iei best-ul la war si zic cei invinsi despre tine ca ai AIM

 

YSaAD5g.gif

2uf7gy0.gif

yljS6Yv.png

V2JRg.gif2vdnLxw.pngV2JRg.gif

P5kfm70.png8hy065o.png

nZZDuAA.png

rmVZMNw.png

sEJctQ3.png

SYdo8kl.png

4rWEHXj.png

rlLEyM4.png

W0ZabhU.pngDOJ8Csc.png

XPUQKPb.png

tumblr_on7cdbONXh1w8gu1go1_500.gif

HsrTbNr.gif

x8bIpl3.gif75f4d209a9250cc81a78bb5547ccb60f.gif0afd7ab4d5d32ecd840686e44aad4d70e9eb4290

Edited by Dany_YTZ7
Link to comment
Share on other sites

Pentru a salva datele in baza de date, va trebui sa trimiti un query. Iti recomand sa inveti SQL inainte de a te apuca de ceva de genul.

 

https://www.w3schools.com/sql/

http://forum.sa-mp.com/showthread.php?t=129183

 

Va trebuie ca atunci cand te deconectezi, sa trimiti un query cu datele pe care le vrei salvate.

Ceva de genul:

new query[128];
format(query, sizeof(query), "UPDATE table SET field = '%d' WHERE id = '%d'", valoarea_1, id_internal_al_jucatorului);
mysql_tquery(db_handle, query);
Link to comment
Share on other sites

Nu dai banii cu GivePlayerMoney, foloseste-te de PlayerInfo[play erid][pCash] += suma de bani pe care vrei sa i-o dai;

zooky are si el dreptatea lui, foloseste aia dupa ce i-ai dat banii cu pCash += suma;

new query[128];
format(query, sizeof(query), "UPDATE table SET Cash = '%d' WHERE id = '%d'", PlayerInfo[playerid][pCash], PlayerInfo[playerid][pSQLID]);
mysql_tquery(db_handle, query);

p.s: uita-te tu sa editezi dupa cum ai tu variabiile in gamemode dar si in baza de date

Edited by Un4m3d_Hokage
Link to comment
Share on other sites

In loc de

GivePlayerMoney(playerid, randmoney);

Foloseste

GivePlayerCash(playerid, randmoney);

Apoi da-i update in database folosindu-te de:

Update(playerid, pCashx);

Nu stiu cum ai tu in gamemode, dar este un exemplu ce ti-am dat mai sus.

Incerc revin cu un raspuns

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.