Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: FinchDon on Sep 17, 2015, 03:34 PM

Title: Array
Post by: FinchDon on Sep 17, 2015, 03:34 PM
Hello I have added this onScriptLoad

hello <- false;


and make this cmd


else if ( ( cmd == "hello" ) || ( cmd == "hello" ) )
{
local plr, b;
for( local i = 0; i < GetMaxPlayers(); i++ )
{
    plr = FindPlayer( i );
if ( ( plr ) && ( hello ) )
    {
if ( b ) b = b + ", " + plr.Name + " (" + hello + ")"
else b = plr.Name + " (" + hello + ")"
    }
}
if ( b ) Message( "**In Game[ Hell Online: [ " + b + " ] ]" );
else Message( "** In Game [ No HEll Online ]." );
}
if ( cmd == "hell")
{
if ( pstats[ player.ID ].Logged == false ) PrivMessage( player, "You are not logged in");
   else
{
hello = true;
PrivMessage( player, "Congratulation You Become New Hell Gate");
}
}


Now when i do /hell it show you become and then i type !hell it show name FinchDon but when i restart server and i join type !hell it show no hell online How i can store data for permanent?
Title: Re: Array
Post by: . on Sep 17, 2015, 04:10 PM
(https://s-media-cache-ak0.pinimg.com/736x/d3/e0/a1/d3e0a1221de8cca4601b8885af1b6f39.jpg)
Title: Re: Array
Post by: Xmair on Sep 17, 2015, 04:13 PM
By using query.
Title: Re: Array
Post by: KAKAN on Sep 17, 2015, 04:17 PM
Array will get removed as soon as you close the server
SO if u want to store permanently use DataBase aka SQLite or MySQL
Title: Re: Array
Post by: . on Sep 17, 2015, 04:25 PM
Quote from: KAKAN on Sep 17, 2015, 04:17 PMArray will get removed as soon as you close the server

WOW, JUST WOW. Wasn't that obvious until now?
Title: Re: Array
Post by: EK.IceFlake on Sep 17, 2015, 06:36 PM
"else if ( ( cmd == "hello" ) || ( cmd == "hello" ) )"
...
Title: Re: Array
Post by: MatheuS on Sep 17, 2015, 09:00 PM
hello <- false;
as will identifying which player? ???
Title: Re: Array
Post by: FinchDon on Sep 18, 2015, 01:42 AM
I am FuZzie Account system it has update function bank= " + bank + " so how can i update array BFMe and save it in db?
Title: Re: Array
Post by: Debian on Sep 18, 2015, 04:33 AM
fuzzie's account system updates player stats when player leaves
Title: Re: Array
Post by: KAKAN on Sep 18, 2015, 04:55 AM
Quote from: Debian on Sep 18, 2015, 04:33 AMfuzzie's account system updates player stats when player leaves
Everyone who has take a look at the code, knows it, He had not taken a look at the code tho!
Title: Re: Array
Post by: FinchDon on Sep 18, 2015, 08:05 AM
i made this

if ( cmd == "a" ) pstats[ player.ID ].BFME += 2;
and this

if ( cmd == "v" ) PrivMessage( player, " " + pstats[ player.ID ].BFME + "." );
Now when i type !a and !v it show BFME 2 and i add this on fuzzie account updater

BFME= " + pstats[ player.ID ].BFME + "



But when i rejoin it show BFME 0 Why?
Title: Re: Array
Post by: KAKAN on Sep 18, 2015, 08:16 AM
What u mean LOL?
Show us the whole system, else nothing gonna happen
Title: Re: Array
Post by: Debian on Sep 18, 2015, 08:24 AM
did you add BMFE in player class?
Title: Re: Array
Post by: FinchDon on Sep 18, 2015, 08:38 AM
Yes
Title: Re: Array
Post by: Mashreq on Sep 18, 2015, 09:46 AM
Are you sure that your BFME score gets saved into database when you leave the server?

Are you settting your BFME array's score from your database when you join the server?
something like this:
function onPlayerJoin( player )
{
//load here your class
local query = QuerySQL( db, "SELECT BFME FROM Your_Account_Table WHERE Name= '" + player.Name + "'" );
if ( GetSQLColumnData( query, 0 ) )
{
pstats[ player.ID ].BFME = GetSQLColumnData( query, 0 );
}
FreeSQLQuery( query );
}
Title: Re: Array
Post by: FinchDon on Sep 18, 2015, 09:56 AM
No Mashreq I Didnt save it in Database i just save them on array pstats array BFME Class When did  i do !v it show 2 Bfme coin on my rejoin it show coins 0
Title: Re: Array
Post by: KAKAN on Sep 18, 2015, 10:14 AM
Because you are saving it on a database, but not loading it when a player joins, so how to know it'll work or not?
Post your onPlayerJoin, and the save query option along with the playerclass
Title: Re: Array
Post by: DizzasTeR on Sep 18, 2015, 10:51 AM
Quote from: FinchDon on Sep 18, 2015, 09:56 AMNo Mashreq I Didnt save it in Database i just save them on array pstats array BFME Class When did  i do !v it show 2 Bfme coin on my rejoin it show coins 0

Tell me, Why do you keep Kills, Deaths, Cash etc for each player in database? Yes, because you want to load it later, the same way you create an array for these to load a class on them the same way as your BFME class, then how do you expect the BMFE class data to get saved without saving it in database?

If even now you didn't get what I mean then don't ask for help again, first try to improve your English so you can understand the solution which people post here for you.
Title: Re: Array
Post by: FinchDon on Sep 18, 2015, 11:00 AM
I understand Doom i add Coins in Accounts Table But i increase them by pstats[ player.ID ].BFME += 9999; This Set it but can't Update it How can i? i Mean On My rejoin it Become 0

I use that

QuerySqL( sqluteDb, "UPDATE Accounts Set Coins= " + pstats[ player.ID ].BFME + " WHERE Name= " + player.Name.tolower(); + " ); Something Like this It show no error but also no Change in Coins
Title: Re: Array
Post by: Mashreq on Sep 18, 2015, 11:20 AM
Answer to questions which I asked before:  Is there a column called BFME in your table which stores accounts.
If yes; are you saving the score when you leave the server?
Title: Re: Array
Post by: FinchDon on Sep 18, 2015, 03:00 PM
Yes I save on Leave But its NOt BFME coloumn it is Coins
Title: Re: Array
Post by: KAKAN on Sep 18, 2015, 03:40 PM
Have u ever thought about creating a table?
Title: Re: Array
Post by: Kratos_ on Sep 18, 2015, 03:46 PM

I didn't save anything in database .
Quote from: FinchDon on Sep 18, 2015, 09:56 AMI Didnt save it in Database i just save them on array pstats array BFME Class



But , I'm saving them too .
Quote from: FinchDon on Sep 18, 2015, 11:00 AMi add Coins in Accounts Table But i increase them by pstats[ player.ID ].BFME += 9999; This Set it but can't Update it How can i? i Mean On My rejoin it Become 0
I use that
QuerySqL( sqluteDb, "UPDATE Accounts Set Coins= " + pstats[ player.ID ].BFME + " WHERE Name= " + player.Name.tolower(); + " ); Something Like this It show no error but also no Change in Coins

Be more clear .
Title: Re: Array
Post by: Thijn on Sep 18, 2015, 06:13 PM
In order to keep something for when you leave, you have to... save it somewhere. Just adding a variable to a class won't let it be saved. You have to edit stuff.

There should be 2 functions you have to edit: The save function, and the load function.
Try to find those 2 functions and add your column to it. You don't have to create another query, just append to the current one. There's no need to make 2 if you can do it in 1.
Title: Re: Array
Post by: FinchDon on Sep 19, 2015, 02:06 AM
Maybe SetCoins and GetCoins i will make it
Title: Re: Array
Post by: KAKAN on Sep 19, 2015, 05:23 AM
LOL! 1st check the database that you have created the table or not, then check what Thijn, Doom_Killer etc have posted, If u can't understand, then this link may help you:- http://www.learnenglish.de/
Title: Re: Array
Post by: FinchDon on Sep 19, 2015, 08:00 AM
Thanks Problem Solve I make SetCoins and GetCoins and its Work Anyway Thanks all
Title: Re: Array
Post by: Thijn on Sep 19, 2015, 10:22 AM
If those functions are doing a query each you might wanna reconsider doing it the easy way...