Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Kratos_

#1
Scripting and Server Management / Re: Error
Sep 18, 2015, 03:51 PM
Quote from: FinchDon on Sep 18, 2015, 10:34 AMfunction SaveStats( player )
{
// body ..............
pstats[ id ] = null;
// body ..............
}

You're clearing the array so that class object have become vanished . Now , you couldn't retrieve function Update which was member of
that object .  You should clear the array after calling the Update function .
#2
Scripting and Server Management / Re: Array
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 .
#3

Quote from: Debian on Sep 15, 2015, 02:07 AMIm trying to test and in this code Accounts and Acc are working fine even Dstats is inserting and updating but not loading column data and each time a player joins dstats will start from 0. acc working fine. 

Note that if(a) not only checks whether a exists but rather those values will also get eliminated which are conventionally false .
A small test in support of this statement :-


local array = [

"123",
null,
"abc",
911,
true,
0.0,
0x28,
3.14,
false,
1,
0

];

foreach( index, values in array )
{
if( values ) print( "position : " + (index+1) );
}



While attempting to retrieve values from the database , you written up this condition :-
Quote from: Debian on Sep 15, 2015, 02:07 AM// Extracted from the body of constructor of class DebianStats
if( ::GetSQLColumnData( query, 2 ) ){


During registration , you're inserting value 0 to 3rd column so that condition will not be satisfied since 0 is conventionally false . Above test could be considered as an experimental evidence for this fact .

Condition should be :-
if ( ::GetSQLColumnData( query, 2 )  != null )

if(a) & if(a != null) are two different variants , where former one does the job of later one plus it also takes care of boolean
entities .
#4

GetSQLColumnData operates over the value returned by query & not the actual table in the database .

local q = QuerySQL( db, "SELECT Pos FROM Houses WHERE ID=" + a );
local Pos = GetSQLColumnData( q, 5 ).tostring();

Your query is selecting just one column "Pos" from the actual table . But , you're attempting to get 6th column which the query never returns . To fix this , simply write this :-

local q = QuerySQL( db, "SELECT Pos FROM Houses WHERE ID=" + a );
// First & only column which is selected through query
local Pos = GetSQLColumnData( q, 0 ).tostring();

OffTopic : You shouldn't select entire table just for counting no of rows .
#5

I guess your GetCash( plr ) function returning either null or it do not have a return statement . So , it is assumed to be null . Otherwise , 0 is considered a valid value to be used with operator / except at denominator . Besides , this error is reproducible this way :-
local a = null;
a = a / 5;
#6

Quote from: KAKAN on Jul 26, 2015, 05:54 AMStill then not wrking

Magnifying callback onPlayerKill :-

-> You're creating victim's spree by passing his instance.
// Increasing victim's spree by 1
IncPlayerSpree(player, 1);


-> You're attempting to announce the victim's spree if spree is 5 or divisible by 5 .
// Starting victim's spree
StartKillingSpree( player );


-> You're attempting to end killer's spree (  who eventually wasn't on any spree ) due to what you did on above steps .
// Ending killer's spree & victim is the man on spree currently
EndKillingSpree(killer,player);


-> Victim's spree reverted back to zero .
// Reverting back victim's spree to 0
if (GetPlayerSpree(player) >= 1) DecPlayerSpree(player,GetPlayerSpree(player));




Conclusion : No one is on spree .

Quote from: KAKAN on Jul 26, 2015, 05:37 AMI said nah, these didn't throw out any error

How're you assuming to get "error messages" ? This isn't syntax error . This is logical error .

You wont get any spree announcement . Because , your StartKillingSpree function checks whether spree status is 5 or its multiple ? While you're reverting it back to 0 in the 4th step I mentioned above . You wont get spree end announcement as well cuz killer wasn't on spree anytime & you're attempting to end his spree .
All this will behave like a blank system . ( On console as well as the ingame ) .

Off-Topic : Why're you creating overheads for all this ? For example your  IncPlayerSpree function could be removed & something like this could be written .

++stats[killer.ID].KillingSpree;
Indeed this whole system need not any overheads except the one Spree function to stop cluttering the playerkill callback .
#7
Quote from: [VSS]Shawn on Jul 25, 2015, 05:43 AMYaar I dont know but on that script it was creater Kratos

There are too many Kratos in this community .

  • [OSK_R]Kratos
  • Krato$
  • [KR]Kratos
  • [VU]Kratos
  • Kr@to$
  • Kratos_The_Power
  • [GOW]Kratos

Did anyone of them gave you scripts ?

The name "Kratos" now became a market-product . Probably they would be fan of that bald guy ( God of war ) .
I wanted to change this nick but too late has been happened now . Btw I have no associations with that script . And what is being leaked actually ? The snippet's source is already published by a guy in HotDogCat's thread .
#8

Quote from: [VSS]Shawn on Jul 25, 2015, 04:04 AMhmmm Kratos leaked script btw thanks for release

Is this me ? Could you be more specific ?
#9

Quote from: Stormeus on Jul 18, 2015, 08:18 PMAlso
Quote from: Kratos_ on Dec 31, 2014, 05:15 AMStormeus mentioned that VC:MP devs haven't  planned to add custom vehicles to 0.4 final release.
This might be in the future versions but not in 0.4.
ayy lmao

This might be planned recently since 0.5 is no longer to come . :D

Quote from: Stormeus on Jul 06, 2015, 01:38 PMWe're probably going to be on 0.4 forever now that we can just push incremental updates.
#10

Quote from: Thijn on Jul 17, 2015, 07:26 PMThat code makes no sense.

if ( plr ) { .. }
else { plr = FindPlayer( plr ); }

When is that ever going to work?

That function will work for sure . The parameter is defined as identifier "plr" which we generally refer to instance . Although being custom , "plr" is symbolized as the "instance holder" due to intensive use by most of the VC:MP scripters while specifying to "target instance" . This myth ends here .

Because , our purpose through "GetPlayer" function is to get the target "instance" . So , it is quite clear that passed argument will not be an instance & indeed would be either player's name or his id . Now , the check if( plr ) at the beginning of the function is useless since we're attempting to check whether an argument to "plr" is passed ? While the fact is that if no argument is passed then it will itself throw error "Wrong Number Of Parameters" & function execution will be seized .

Thereafter we're checking whether the passed argument is a "numeric string" . If then we're converting this string to integer & passing this as an argument to function FindPlayer which will attempts to check whether there is an valid player instance corresponding to this . This checking will be based on id . Thereafter we're assigning the result to "plr" which would now contain either an instance or null .
Actually this could be considered as identical to compound assignment ( aka short-hand ) :-

function IsEven( num )
{
   num %= 2;
   num == 0 ? print("Even") : print("Not even");
}

Thereafter if "plr" got an instance then we're attempting to return it otherwise returning false . The other check would be on the basis of name & not id .

function GetPlayer( plr )
{
    // checking if the argument to plr is passed [Useless]
    if ( plr )
    {
        // checking if the passed argument is a numeric string
        if ( IsNum( plr ) )
        {
            // 1. converting numeric string "plr" to actual integer
            // 2. passing this as an argument to FindPlayer
            // 3. "plr" now contain either an instance or null instead of id
           
            plr = FindPlayer( plr.tointeger() );
           
            // 1.checking whether an instance has been received ?
            // 2. returning the resultant instance
           
            if ( plr ) return plr;
           
            // otherwise returning false
            else return false;
        }
    // if the passed argument isn't numeric string
    else
        {     
            // 1. passing the string (player's name) to FindPlayer
            // 2. "plr" now contain either an instance or null instead of name
           
            plr = FindPlayer( plr );
           
            // 1.checking whether an instance has been received ?
            // 2. returning the resultant instance
           
            if ( plr ) return plr;
           
            // otherwise returning false
            else return false;
        }
    }
    else return false; // [Useless]
}

Failure case scenario : This function will work in most cases but still struggle at something . For example , if you're passing it a number then check will be made on the basis of id & not player's name . What if someone joined the server with nick 123456 . If we'll write /kick 1234 , then it will return invalid player . Because , as I said earlier , it will recognize 1234 as an id & then attempts to check it . Truth is that there is no such id actually exist . This could easily be fixed by making an additional check once checking through id has been failed or checking via name before id . However I consider it a bit overkill since numeric names look absurd . So , I prefer
using this :-

local plr = IsNum(text) ? FindPlayer(text.tointeger() ) : FindPlayer(text);
And for the number lovers this one :-

if( IsNum(player.Name) ) KickPlayer( player );
#11
Support / Re: Clanstats Error Sometimes
Jun 16, 2015, 08:04 AM

The clan tag needs to be split for the sake of generalization so that people could use as many customized tags as they want & the server will treat all those variations as part of an identical entity as long as alphanumeric values unchanged .

Whenever we need to split a string , we need to specify exactly where we want to perform those splittings . Those junctions are a heap of characters ( present in target string ) that we need to pass to split function as the 2nd argument .

Thereafter , split will return an array of sub-strings . Since , these junctions define the procedures for manufacturing sub-strings so they could be called as separaters informally .

The error is pretty obvious since you defined some locals & used keyword 'local' once so you need to use a comma (,) instead of a semi colon (;) .

#12
Support / Re: Clanstats Error Sometimes
Jun 11, 2015, 08:28 AM

Include an underscore in character class of Single Delimiter . This way :-

local S_DELIM = regexp(@"(\w.+[.*=_]+)") ;
One more vulnerability is that Findclan will return null in case no clan tag is found & then in get tag function you're attempting to
convert it to upper case without validating the actual clan tag existence .

// will throw error index toupper doesnot exist in case of normal player join [ Without any tag ]
local Tag = FindClan( string ).toupper(),

Tip -> Regexp becomes slow often . So , create a new search pattern entry only when previous search pattern fails to match , keeping the most frequent search pattern at the top to reduce some number of cycles .
#13
Off-Topic General / Re: Scripting challenges!
Jun 10, 2015, 11:58 AM

** Kratos_ was returning to home . ( Just a 5 min drive to home )
** Kratos_ checked mobile . ( Thinks, hmm ok. Something to post )
** Kratos_ reached home & opened lappy . Writes some bunches of code .
** Kratos_ opened forum & boom all fun destroyed . ( S.L.C disclosed )

Btw here it is ,

[spoiler]function onScriptLoad()
{
_test_();
}

// function for defining & printing array entities
function _test_(ctr=0)
{
// sample array holding the entities
local array = [ "mercury", "venus", "earth", "mars", "jupiter", "saturn", "uranus", "neptune" ];
// printing the array slot indexed at 'ctr'
print(array[ctr]);
// updating the counter by 1
++ctr;
// checking if the updated counter goes beyond the range of array slots ( 0 - n-1 )
if( ctr >= array.len() ) return 0;
// calling the function with updated counter [ Tail Recursion ]
_test_(ctr);

}
[/spoiler]
#14
You aren't checking whether player is in vehicle or not . Something of this type :-
local veh = player.vehicle;
if(! veh ) // not in vehicle
else
{
// fix vehicle
}
#15
AFAIK there isn't any text editor which contains VC:MP 0.4 squirrel syntax by default .

However , you could program some text editors like sublime or Atom to do this task .