SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 10/02/2018, 12:24 PM   #4041
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

Is there any problems if I do this?

PHP Code:
CreateVehicleEx__(typeFloat:xFloat:yFloat:zFloat:ac1c2respawn=300addsiren=0)
{
    new 
q;
    if((
CreateVehicle(typexyzac1c2respawnaddsiren)) == INVALID_VEHICLE_ID) return INVALID_VEHICLE_ID;

    
CallLocalFunction("OnVehicleCreate""iiffffiiii"qtypexyzac1c2respawnaddsiren);
    return 
q;
}
#if defined _ALS_CreateVehicle
    #undef CreateVehicle
#else
    #define _ALS_CreateVehicle
#endif
#define CreateVehicle CreateVehicleEx__

// later..

#include <YSI\y_hooks>
hook OnVehicleCreate(vehicleid)
{
        
// i don't need info about vehicle's spawn pos here, so there is just vehicleid as parameter.

I know it works and it compiles, but can this cause memory leaks / other problems?

EDIT: or if I use SetTimerEx instead of CallLocalFunction
GaByM is offline   Reply With Quote
Old 12/02/2018, 07:21 PM   #4042
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

Quote:
Originally Posted by GaByM View Post
Is there any problems if I do this?

PHP Code:
CreateVehicleEx__(typeFloat:xFloat:yFloat:zFloat:ac1c2respawn=300addsiren=0)
{
    new 
q;
    if((
CreateVehicle(typexyzac1c2respawnaddsiren)) == INVALID_VEHICLE_ID) return INVALID_VEHICLE_ID;

    
CallLocalFunction("OnVehicleCreate""iiffffiiii"qtypexyzac1c2respawnaddsiren);
    return 
q;
}
#if defined _ALS_CreateVehicle
    #undef CreateVehicle
#else
    #define _ALS_CreateVehicle
#endif
#define CreateVehicle CreateVehicleEx__

// later..

#include <YSI\y_hooks>
hook OnVehicleCreate(vehicleid)
{
        
// i don't need info about vehicle's spawn pos here, so there is just vehicleid as parameter.

I know it works and it compiles, but can this cause memory leaks / other problems?

EDIT: or if I use SetTimerEx instead of CallLocalFunction

1. ^^^

2. mysql log-core.log:
Code:
[ERROR] signal 11 (SIGSEGV) catched; shutting log-core down (errno: 0, signal code: 1, exit status: 1)
What does this means?
GaByM is offline   Reply With Quote
Old 28/02/2018, 04:25 PM   #4043
GospodinX
Big Clucker
 
Join Date: Nov 2017
Posts: 148
Reputation: 20
Default Re: Little coding questions - For general minor queries 5

Do I need to hide textdraws onplayerdisconnect?
GospodinX is offline   Reply With Quote
Old 04/03/2018, 09:05 AM   #4044
KayJ
Gangsta
 
KayJ's Avatar
 
Join Date: Apr 2014
Posts: 678
Reputation: 64
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by GospodinX View Post
Do I need to hide textdraws onplayerdisconnect?
Yes, otherwise it will be bugged for player who joins after him.
KayJ is offline   Reply With Quote
Old 16/03/2018, 07:57 AM   #4045
Aeny
Little Clucker
 
Join Date: Apr 2010
Posts: 2
Reputation: 0
Default Re: Little coding questions - For general minor queries 5

First post after a long time of lurking.

It seems OnPlayerEnterVehicle doesn't get called when a player wants to enter a vehicle as driver and the doors are locked, but does get called when the doors are unlocked. OnPlayerEnterVehicle always gets called for passengers even when doors are locked.

Is this a known issue and is there a workaround for this? I know the animation not getting triggered is a known thing, but the callback not being called?
Aeny is offline   Reply With Quote
Old 16/03/2018, 12:04 PM   #4046
ISmokezU
Gangsta
 
Join Date: Aug 2016
Posts: 542
Reputation: 75
Default Re: Little coding questions - For general minor queries 5

Could be an error in your code. Do you mind sharing it?
ISmokezU is offline   Reply With Quote
Old 19/03/2018, 07:59 AM   #4047
Aeny
Little Clucker
 
Join Date: Apr 2010
Posts: 2
Reputation: 0
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by ISmokezU View Post
Could be an error in your code. Do you mind sharing it?
Used following code to reproduce the issue I'm having

Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	new playerAnnouncement[128];
	format(playerAnnouncement, sizeof(playerAnnouncement), "playerid %d attempted to enter vehicleId %d (passenger %d)", playerid, vehicleid, ispassenger);
	SendClientMessage(playerid, 0xfffafa, playerAnnouncement);
	return 1;
}
The rest of the script is just bare.pwn as included within the server download.
Aeny is offline   Reply With Quote
Old 03/05/2018, 08:53 AM   #4048
Amads
Huge Clucker
 
Amads's Avatar
 
Join Date: Feb 2012
Location: Poland
Posts: 206
Reputation: 51
Default Re: Little coding questions - For general minor queries 5

Am I retarded?
PHP Code:
new Float:fPos[3];
fPos = {2487.25122401.240211.4465}; 
Code:
A:\path\gm.pwn(2) : warning 213: tag mismatch
Amads is offline   Reply With Quote
Old 06/05/2018, 02:12 PM   #4049
Amads
Huge Clucker
 
Amads's Avatar
 
Join Date: Feb 2012
Location: Poland
Posts: 206
Reputation: 51
Default Re: Little coding questions - For general minor queries 5

Code:
new strNames[500][4][MAX_PLAYER_NAME];
How resource heavy is an array like this one (if any)?
Amads is offline   Reply With Quote
Old 06/05/2018, 11:09 PM   #4050
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 2,852
Reputation: 675
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by Amads View Post
Code:
new strNames[500][4][MAX_PLAYER_NAME];
How resource heavy is an array like this one (if any)?
266000 Bytes = 259,765625 KiB - if global or static
or
10000 Bytes = 9,765625 KiB - if local, the remaining bytes will be allocated in stack

You can calculate the values by yourself or compile an empty file with this array and the -d3 flag (to get debug information)
Nero_3D 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 07:37 PM.


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