SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 21/06/2016, 04:04 PM   #171
codectile
Huge Clucker
 
codectile's Avatar
 
Join Date: Jul 2014
Posts: 316
Reputation: 116
Default Re: Plugin development guide

Quote:
Originally Posted by Yashas View Post
Why is it needed? PAWN cell is 4 bytes and only the first byte stores the character. So copying characters should be same as copying cells?
Yes, each pawn cell is of 4 bytes. But do you really think that strings in the abstract machine are in a such simple format?
Try using amx_GetString and check whether you get same results or not.

EDIT:

Shouldn't this: string_strncpy(AMX amx, cell params)
be: string_strncpy(AMX* amx, cell* params) ?
codectile is offline   Reply With Quote
Old 22/06/2016, 07:10 AM   #172
Yashas
Gangsta
 
Join Date: Jun 2012
Location: India
Posts: 875
Reputation: 261
Default Re: Plugin development guide

Quote:
Originally Posted by codectile View Post
Yes, each pawn cell is of 4 bytes. But do you really think that strings in the abstract machine are in a such simple format?
Srtings are arrays so what is so different? Each character is stored in each cell linearly in PAWN (unpacked strings) so I can treat it as it was an array but with a null at the end?

Of course, that code won't work with packed strings and I don't use packed strings so I won't need to add support for that.

I have many more algorithms which work on arrays which use the exact same method (directly modifying the contents through pointers) and they work.

Quote:
Originally Posted by codectile View Post
Try using amx_GetString and check whether you get same results or not.
And SetString again? will reply after doing it...

Quote:
Originally Posted by codectile View Post
EDIT:

Shouldn't this: string_strncpy(AMX amx, cell params)
be: string_strncpy(AMX* amx, cell* params) ?
Yea, I asked about it with few people in skype and copied the code from the skype chat which is why few * are missing.

Here is a copy from the actual source.
Code:
cell AMX_NATIVE_CALL string_strncpy(AMX* amx, cell* params)
	{
		cell* dest = NULL;
		cell* source = NULL;

		amx_GetAddr(amx, params[1], &dest);
		amx_GetAddr(amx, params[2], &source);

		int num = static_cast<int>(params[3]);
		unsigned int size_dest = static_cast<unsigned int>(params[4]);
		unsigned int size_src = static_cast<unsigned int>(params[5]);

		while (num-- && size_dest-- && size_src--) {
			logprintf("%d", *(source));
			*dest++ = *source++;
		}
		*dest = 0;
		return 0;
	}
------------------------------------------------------------
wtf I sware I did not change the code at all =,= the array size is 11 and it works today -_-
Code:
[13:05:59] t
[13:05:59] e
[13:05:59] s
[13:05:59] t
[13:05:59]  
[13:05:59] s
[13:05:59] t
[13:05:59] r
[13:05:59] i
[13:05:59] n
[13:05:59] test strin
Yashas is offline   Reply With Quote
Old 22/06/2016, 08:52 AM   #173
codectile
Huge Clucker
 
codectile's Avatar
 
Join Date: Jul 2014
Posts: 316
Reputation: 116
Default Re: Plugin development guide

Yes, it works. I tried out your code yesterday and it worked out for me. I was about to edit my comment but unfortunately had no time.
codectile is offline   Reply With Quote
Old 05/12/2016, 08:30 PM   #174
kurta999
High-roller
 
kurta999's Avatar
 
Join Date: Apr 2009
Location: Slovakia (HU)
Posts: 1,384
Reputation: 574
Default Re: Plugin development guide

Hi guys!

I've just created a new way of setting amx parameters from plugin.

Code:
// native GetSpawnInfo(playerid, &teamid, &modelid, &Float:spawn_x, &Float:spawn_y, &Float:spawn_z, &Float:z_angle, &weapon1, &weapon1_ammo, &weapon2, &weapon2_ammo,& weapon3, &weapon3_ammo);

CAMXParameters amxparams(amx, params, 2);

amxparams.Add(pSpawn->byteTeam);
amxparams.Add(pSpawn->iSkin);
amxparams.Add(pSpawn->vecPos);
amxparams.Add(pSpawn->fRotation);
amxparams.Add(pSpawn->iSpawnWeapons[0]);
amxparams.Add(pSpawn->iSpawnWeaponsAmmo[0]);
amxparams.Add(pSpawn->iSpawnWeapons[1]);
amxparams.Add(pSpawn->iSpawnWeaponsAmmo[1]);
amxparams.Add(pSpawn->iSpawnWeapons[2]);
amxparams.Add(pSpawn->iSpawnWeaponsAmmo[2]);

Does it looks good? I'm waiting for other people's opinion
kurta999 is online now   Reply With Quote
Old 05/12/2016, 08:56 PM   #175
Yaa
Banned
 
Join Date: May 2016
Location: = GetPlayerHouse("Yaa", 0.2);
Posts: 638
Reputation: 42
Default Re: Plugin development guide

PHP Code:
Loading pluginEmailSender
 Plugin does not conform to architecture
.
 
Failed
what the hell ?
Yaa is offline   Reply With Quote
Old 05/12/2016, 09:13 PM   #176
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 12,007
Reputation: 1354
Default Re: Plugin development guide

Quote:
Originally Posted by Yaa View Post
PHP Code:
Loading pluginEmailSender
 Plugin does not conform to architecture
.
 
Failed
what the hell ?
Literally the first result in google..
__________________
Life is like riding a bicycle. To keep your balance, you must keep moving.

[Tutorial] How to use SQLite
[FilterScript] Tune System



www.SF-SE.net
play.sf-se.net:7777
Play now!
Konstantinos is offline   Reply With Quote
Old 05/12/2016, 09:51 PM   #177
Yaa
Banned
 
Join Date: May 2016
Location: = GetPlayerHouse("Yaa", 0.2);
Posts: 638
Reputation: 42
Default Re: Plugin development guide

Quote:
Originally Posted by Konstantinos View Post
Literally the first result in google..
on this ?

PHP Code:
#include "../SDK/plugin.h"

#include "../easendmailobj.tlh"

#include <tchar.h>


using namespace EASendMailObjLib;

typedef void
(*logprintf_t)(charformat, ...)
;

logprintf_t
logprintf

;

void
**ppPluginData
;

extern void
*pAMXFunctions
;

PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData)
{
     
pAMXFunctions ppData[PLUGIN_DATA_AMX_EXPORTS];
    
logprintf = (logprintf_t)ppData[PLUGIN_DATA_LOGPRINTF];
    return 
1;
}

PLUGIN_EXPORT void PLUGIN_CALL Unload()
{
    
logprintf("[SAP] SA-MP Email Sender v1.0 LikeMrYassine");
}

static 
cell AMX_NATIVE_CALL SendEmail(char Lamxchar *Lparams)
{
    
logprintf("[SAP] Creating The Email App ....");
    
logprintf("[SAP] Installing it ....");
    
logprintf("[SAP] Forwarding For Email Ports...");
    
logprintf("[SAP] Loading The Plugin....");
    
logprintf("[SAP] SA-MP Gmail Sender v1.0 By LikeMrYassine ");

    ::
CoInitialize(NULL);

    
IMailPtr oSmtp NULL;
    
oSmtp.CreateInstance("EASendMailObj.Mail");
    
oSmtp->LicenseCode _T("TryIt");

    
// Set your sender email address
    
oSmtp->FromAddr _T("sampplugin@gmail.com");

    
// Add recipient email address

    
oSmtp->AddRecipientEx(_T(amx), 0);

    
// Set email subject
    
oSmtp->Subject _T("This Email Sended From SA-MP Server");

    
// Set email body
    
oSmtp->BodyText _T(params);

    
// Your SMTP server address
    
oSmtp->ServerAddr _T("smtp.gmail.com");

    
// User and password for ESMTP authentication, if your server doesn't 
    // require User authentication, please remove the following codes.

    
oSmtp->UserName _T("sampplugin@gmail.com");
    
oSmtp->Password _T("");

    
// If your smtp server requires SSL connection, please add this line
    
oSmtp->SSL_init();

    
_tprintf(_T("Start to send email ...\r\n"));

    if (
oSmtp->SendMail() == 0)
    {
        
_tprintf(_T("Email was sent successfully!\r\n"));
    }
    else
    {
        
_tprintf(_T("Failed to send email with the following error: %s\r\n"),
            (const 
TCHAR*)oSmtp->GetLastErrDescription());
    }

    if (
oSmtp != NULL)
        
oSmtp.Release();
    return 
1
}

AMX_NATIVE_INFO projectNatives[] =
{
    { 
"SendEmail" }
};

PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports()
{
    return 
SUPPORTS_VERSION SUPPORTS_AMX_NATIVES;
}

PLUGIN_EXPORT int PLUGIN_CALL AmxLoad(AMX *amx)
{
    return 
amx_Register(amxprojectNatives, -1);

Yaa 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
SA-MP 0.3c in development Kalcor News and Updates 889 19/09/2014 04:39 PM
[Question] Plugin Load Failed : Plugin Does not conform to architecture. Gamer_Z Plugin Development 2 09/06/2011 06:42 AM
0.3b Development bar gone WackoX General 94 02/08/2010 10:17 PM
A guide to install Jacob's IRC plugin? Celson Server Support 5 09/06/2009 07:06 AM


All times are GMT. The time now is 09:01 PM.


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