SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 01/12/2017, 04:49 PM   #3991
rfr
Banned
 
Join Date: Nov 2017
Posts: 228
Reputation: 43
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by GaByM View Post
PHP Code:
#include <a_samp>
main()
{
    new 
k;
    if(
k)
        return 
1;
    else
    {
    }
    return 
1;

PHP Code:
D:\SERVER\gamemodes\a.pwn(10) : warning 225unreachable code 
Why?
PHP Code:
#include <a_samp> 
main() 

    new 
k
    if(
k
        return 
1
    else if (!
k
    { 
    } 
    return 
1

try this.
rfr is offline   Reply With Quote
Old 01/12/2017, 08:20 PM   #3992
Mister0
Huge Clucker
 
Mister0's Avatar
 
Join Date: Aug 2015
Posts: 220
Reputation: 19
Default Re: Little coding questions - For general minor queries 5

Hi, this error "Array index out of bounds" show when you acces an element past over you defined variable like new variable[20] and you acces 20 or 21 etc.
So I have this error

Code:
[20:58:23] [debug] AMX backtrace:
[20:58:23] [debug] #0 00068d9c in ?? (1) from rpggm.amx
[20:58:23] [debug] #1 001c3860 in public TimerSeconds () from rpggm.amx
[20:58:24] [debug] Run time error 4: "Array index out of bounds"
[20:58:24] [debug]  Accessing element at index 27 past array upper bound 25
so this error show me I have a variable [26] and I acces upper element, but I can sure you I have no variable with value [24] [25] or [26]
So I ask you what else can produce this error?
Mister0 is offline   Reply With Quote
Old 01/12/2017, 09:05 PM   #3993
Mister0
Huge Clucker
 
Mister0's Avatar
 
Join Date: Aug 2015
Posts: 220
Reputation: 19
Default Re: Little coding questions - For general minor queries 5

Solved thx anyway

Last edited by Mister0; 01/12/2017 at 09:37 PM.
Mister0 is offline   Reply With Quote
Old 02/12/2017, 09:19 AM   #3994
GaByM
Big Clucker
 
GaByM's Avatar
 
Join Date: Jan 2014
Location: Romania
Posts: 112
Reputation: 10
Default Re: Little coding questions - For general minor queries 5

When using mysql_tquery, should I use cache_delete(x) if I don't use cache_save()? AFAIK the result isn't stored by default, but I want to be sure, so I won't get memory leaks.
GaByM is offline   Reply With Quote
Old 02/12/2017, 10:02 AM   #3995
NealPeteros
Gangsta
 
NealPeteros's Avatar
 
Join Date: Dec 2015
Location: GetPlayerCountry(playerid);
Posts: 654
Reputation: 51
Default Re: Little coding questions - For general minor queries 5

I'm not really good at mapping. Is it possible for the text of the object below to be changed?

NealPeteros is offline   Reply With Quote
Old 02/12/2017, 11:49 AM   #3996
NealPeteros
Gangsta
 
NealPeteros's Avatar
 
Join Date: Dec 2015
Location: GetPlayerCountry(playerid);
Posts: 654
Reputation: 51
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by [HLF]Southclaw View Post
Yeah you can change that, either via SetObjectMaterialText or (when 0.3.8 comes out) via changing the texture and providing the new object+texture as a downloadable asset.
Used SetObjectMaterialText but had a little problem

Code:
new obj0 = CreateObject(3715, 1362.1599, -1036.0848, 31.3095, 0.0000, 0.0000, 84.1780);
SetObjectMaterialText(obj0, "SAMPTESTSAMPTEST SAMPTEST", 2, 120, "Castellar", 60, 0, 0xFFFFFFFF, 0xFF000000, 2);
RESULT:
NealPeteros is offline   Reply With Quote
Old 02/12/2017, 06:34 PM   #3997
NealPeteros
Gangsta
 
NealPeteros's Avatar
 
Join Date: Dec 2015
Location: GetPlayerCountry(playerid);
Posts: 654
Reputation: 51
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by [HLF]Southclaw View Post
You'll have to just pad it with spaces, there's sadly no way to alter UV coordinates with material functions.
It still doesn't work, the same result.
NealPeteros is offline   Reply With Quote
Old 03/12/2017, 04:41 PM   #3998
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

Which one is preferable to update the car's health?
- Using OnPlayerUpdate and checking if the player is inside a vehicle
- A timer though every vehicle running every second/500 ms
- A timer though every player running every second/500ms
__________________
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 03/12/2017, 06:53 PM   #3999
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 [HLF]Southclaw View Post
The answer would depend on your average player count, amount of vehicles and future scale plans.
Yep, obivously. My bad.
Average 60-80 players & +1000 vehicles.

I'm asking myself between a timer and OnPlayerUpdate. I find the timer will be not accurate for the vehicle's health and OnPlayerUpdate is called too much time for this use.
__________________
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 03/12/2017, 07:00 PM   #4000
Lucases
Huge Clucker
 
Join Date: Jul 2017
Posts: 216
Reputation: 11
Default Re: Little coding questions - For general minor queries 5

Use a timer. As you said OnPlayerUpdate gets called 30+ times in a second, so isn't very efficient when there are a lot of players driving
Lucases 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 11:21 PM.


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