SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 26/11/2016, 12:57 AM   #3141
Karolukas123
Huge Clucker
 
Join Date: Nov 2013
Posts: 391
Reputation: 8
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by Garwan50 View Post
hey,

in the beginning of my filterscript i load all animations, just to be sure that they will be played without having to type the command twice.
However it crashed the player, is there a safer way to do it ? Or is it just impossible to load every libraries at the same time?

thanks!
its easy mate.. just create for example

StartingSomeAnimation(playerid) {
ApplyAnimation(playerid, "CHAINSAW", "CSAW_1", 4.1, 1, 0, 0, 0, 0, 1);

How to use:

in command or else
StartingSomeAnimation(playerid);
Karolukas123 is offline   Reply With Quote
Old 26/11/2016, 01:24 AM   #3142
SickAttack
High-roller
 
Join Date: Dec 2013
Posts: 4,761
Reputation: 754
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by Garwan50 View Post
hey,

in the beginning of my filterscript i load all animations, just to be sure that they will be played without having to type the command twice.
However it crashed the player, is there a safer way to do it ? Or is it just impossible to load every libraries at the same time?

thanks!
Preload the libraries when the player spawns, or wherever you want.
SickAttack is offline   Reply With Quote
Old 26/11/2016, 01:38 PM   #3143
Garwan50
Big Clucker
 
Join Date: Jul 2013
Posts: 107
Reputation: 2
Default Re: Little coding questions - For general minor queries 5

hey,

i did that, i tried when the player connect, and then when the player spawn.

Maybe i'll try to load animations with a timer, not everything at once
Garwan50 is offline   Reply With Quote
Old 01/12/2016, 06:15 PM   #3144
Hansrutger
Gangsta
 
Hansrutger's Avatar
 
Join Date: May 2011
Location: Sweden
Posts: 760
Reputation: 161
Default Re: Little coding questions - For general minor queries 5

What is ackslimit for precisely? I've read here, which redirected me here. So I'm guessing it has to do with allowed connections or something, but is there an exact definition somewhere? (Sorry if it's stated somewhere obvious, I have not been able to reach there then...).
__________________


Hansrutger is offline   Reply With Quote
Old 02/12/2016, 09:30 PM   #3145
Dayrion
High-roller
 
Dayrion's Avatar
 
Join Date: Jan 2016
Location: France
Posts: 1,915
Reputation: 258
Default Re: Little coding questions - For general minor queries 5

There is a way to detect the number of time a numeral is repeated in a number?
Example:
3331 : 3 is repeated 3 times and 1, one time.
9955: 9 & 5 2 times
__________________
actor_plus - v5.0.2
I'm a goner, somebody catch my breath,
I'm a goner, somebody catch my breath
Dayrion is offline   Reply With Quote
Old 02/12/2016, 09:32 PM   #3146
SickAttack
High-roller
 
Join Date: Dec 2013
Posts: 4,761
Reputation: 754
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by Dayrion View Post
There is a way to detect the number of time a numeral is repeated in a number?
Example:
3331 : 3 is repeated 3 times and 1, one time.
9955: 9 & 5 2 times
Loop, array, done.
SickAttack is offline   Reply With Quote
Old 02/12/2016, 09:36 PM   #3147
Dayrion
High-roller
 
Dayrion's Avatar
 
Join Date: Jan 2016
Location: France
Posts: 1,915
Reputation: 258
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by SickAttack View Post
Loop, array, done.
I've already tried.
PHP Code:
Repeat(number)
{
    static
        
nb[4],
        
done[10],
        
a[4] = {111};
    
#pragma unused done, nb, a

    
nb[0] = number 1000;
    
nb[1] = (number 1000) / 100;
    
nb[2] = (number 100) / 10;
    
nb[3] = number 10;
    
printf("%i & %i & %i & %i"nb[0], nb[1], nb[2], nb[3]);
    for(new 
i4i++)
    {
        
printf("\n i: %i"i);
        for(new 
j4j++)
        {
            
printf("j: %i  %i & %i"jnb[i], nb[j]);
            if(
nb[i] == nb[j] && != j)
            {
                
printf("Le nombre %i est repete (i: %i & j: %i)"nb[i], ij);
                
done[nb[i]]++;
                
// if(a[i] >= 3)
                //     return a[i];
            
}
        }
    }
    for(new 
i10i++)
    {
        
printf("Le nombre %i est repete %ix"idone[i]);
    }
    return 
1;

__________________
actor_plus - v5.0.2
I'm a goner, somebody catch my breath,
I'm a goner, somebody catch my breath
Dayrion is offline   Reply With Quote
Old 02/12/2016, 09:41 PM   #3148
SickAttack
High-roller
 
Join Date: Dec 2013
Posts: 4,761
Reputation: 754
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by Dayrion View Post
I've already tried.
PHP Code:
// ** INCLUDES

#include <a_samp>

// ** MAIN

main()
{
    print(
"Loaded \"count_numbers_in_string.amx\".");

    new array[
10];
    
CountNumbersInString("1672893871653409172564", array);

    for(new 
0sizeof(array); ++)
    {
        
printf("%d was found %d time(s) in string"i, array[i]);
    }
}

// ** CALLBACKS

public OnGameModeInit()
{
    return 
1;
}

public 
OnGameModeExit()
{
    return 
1;
}

// ** FUNCTIONS

stock CountNumbersInString(const string[], array[])
{
    new 
temp[2];
    for(new 
0strlen(string); j++)
    {
        
temp[0] = string[i];
        array[
strval(temp)] ++;
    }
    return 
1;

SickAttack is offline   Reply With Quote
Old 02/12/2016, 09:49 PM   #3149
Dayrion
High-roller
 
Dayrion's Avatar
 
Join Date: Jan 2016
Location: France
Posts: 1,915
Reputation: 258
Default Re: Little coding questions - For general minor queries 5


Thanks...
__________________
actor_plus - v5.0.2
I'm a goner, somebody catch my breath,
I'm a goner, somebody catch my breath
Dayrion is offline   Reply With Quote
Old 02/12/2016, 10:00 PM   #3150
RaZVaN ^ xD
Huge Clucker
 
Join Date: Jul 2012
Posts: 292
Reputation: 14
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by Dayrion View Post
PHP Code:
//code 
That code reminds me of the first year of C programming courses in highschool. I remember this was one of our homeworks.

Let me fix that for you:
Code:
Repeat(number) {
	new count[10];
	
	if(number < 0) 
		number = -number; // this algorithm won't work properly on negative number since array indexes must be positive
	
	while(number) {
		new digit = number%10;
		count[digit]++;
		number /= 10;
	}
	
	for(new i = 0; i < 10; ++i) {
		printf("Digit %d - %d times", i, count[i]);
	}
}
The difference between my code and SickAttack's is that mine takes the number as an integer, while his takes it as a string.
RaZVaN ^ xD is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to make a soldier aotumaticly be general when the general dies ? AlbanianGuy Scripting Help 35 13/05/2012 03:35 PM
Minor problem Desert Help Archive 4 17/03/2010 06:24 PM
Counting with mysql queries actiwe Help Archive 2 26/02/2010 02:36 PM
SQL queries using GROUP BY Dabombber Help Archive 1 05/10/2009 07:47 PM


All times are GMT. The time now is 08:12 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.