SA-MP Gamemodes with PHP
#81

Quote:
Originally Posted by Kikito
Посмотреть сообщение
Had you built the latest SAMPGDK release?
Updated the plugin source code for the new API and stuff?

If you just edited the functions, and added the new ones in the PHP side, it ain't going to do nothing.

I haven't updated this plugin yet because I don't have almost time for myself, and it's quite a large amount of work.
So in my free time, instead being developing stuff, i prefer to spend time with my family.

About the "amx/amx.h"
that's related to the plugin development sdk.
Yeah I built/installed sampgdk.

Updating plugin for 0.3z (both php framework and plugin) only costed 2 hours to me. =D Plugin's structure is easy, it doesn't take too much time.

And yeah problem is related with sdk, and most probably with this commit: https://github.com/Zeex/sampgdk/comm...2fcafb834a106a

Zeex removed sdk from gdk's itself and currently we're pointing sdk directory with CMAKE_SDK flag, this helps on building GDK but doesn't help on building SAMPHP :/

This commit was made 2 months ago(relatively new) and no one suffer from this problem in net, so probably problem is in this commit.
Reply
#82

Why didn't you post any download link ?
Reply
#83

Because I was still working on it.

I will release it tomorrow. Stay tuned everybody =D
Reply
#84

Quote:
Originally Posted by erorcun
Посмотреть сообщение
Because I was still working on it.

I will release it tomorrow. Stay tuned everybody =D
Staying =)
And could you provide sources for 0.3z version? I tried to update this plugin too, but had problems with amx.h
Reply
#85

nice
Reply
#86

Callbacks works but natives don't, PHP gives "Undefined function" for them - only the ones which isn't in GDK works(AMXNativeExists etc.) so problem could be in GDK, current files on repo is in beta stage, last release was 4 months ago.

Is anyone have idea?
Reply
#87

Quote:
Originally Posted by erorcun
Посмотреть сообщение
Callbacks works but natives don't, PHP gives "Undefined function" for them - only the ones which isn't in GDK works(AMXNativeExists etc.) so problem could be in GDK, current files on repo is in beta stage, last release was 4 months ago.

Is anyone have idea?
Like I said, you need to build the source code of GDK [from github] and use it.
The binary packages to download are outdated.

I've attached to this post the "compiled" SAMPGDK package for windows.
However, it isn't the most recent[built for 0.3z].
Reply
#88

Quote:
Originally Posted by Kikito
Посмотреть сообщение
Like I said, you need to build the source code of GDK [from github] and use it.
The binary packages to download are outdated.
....

I said "I built/installed it" in previous page so I compiled last build. I made changes on it ever.
Reply
#89

Quote:
Originally Posted by erorcun
Посмотреть сообщение
....

I said "I built/installed it" in previous page so I compiled last build. I made changes on it ever.
Sorry, I just misunderstood.[shit happens]
Anyways, some functions in the newest sampgdk have been removed.
You need to do a work around.
Reply
#90

I need help from experienced C++ coders.

Problem is I can't add function to PHP with the same name of any GDK function. I.e. I added PHP_FUNCTION(abcd) and tried it in-game, and it worked, but the same content with PHP_FUNCTION(SetGameModeText) doesn't work. So GDK functions creating problem while importing them with exact names to PHP.

Is anyone know something about that?
Reply
#91

Ok, I finished just now and everything works perfect. I will release soon. All problems' source was GDK, it's buggy.

Also thanks to Kikito. (and Zeex for not answering my PM)
Reply
#92

Quote:
Originally Posted by erorcun
Посмотреть сообщение
Ok, I finished just now and everything works perfect. I will release soon. All problems' source was GDK, it's buggy.

Also thanks to Kikito. (and Zeex for not answering my PM)
It's very cool, I'm in great anticipation for how revisions Linux and Windows, THANK YOU!
Reply
#93

Okay, here it is fixed GDK and SAMPHP.

This zip contains:

1- SAMPGDK's fixed include folder (you must download source and use this include folder for compiling) and .so file for Linux.
2- SAMPHP sources, server files and again .so files only for Linux.

Could be great if someone compile it for Windows.

Also I've fixed little object/playerobject handling problem in framework.

Instructions still same, you must install libphp5.

Also CreateExplosionForPlayer has forgotten in GDK, so I left it commented in framework files =D

Enjoy!
Reply
#94

Quote:
Originally Posted by erorcun
Посмотреть сообщение
Okay, here it is fixed GDK and SAMPHP.

This zip contains:

1- SAMPGDK's fixed include folder (you must download source and use this include folder for compiling) and .so file for Linux.
2- SAMPHP sources, server files and again .so files only for Linux.

Could be great if someone compile it for Windows.

Also I've fixed little object/playerobject handling problem in framework.

Instructions still same, you must install libphp5.

Also CreateExplosionForPlayer has forgotten in GDK, so I left it commented in framework files =D

Enjoy!
Great work!
I'll try to compile this for Windows, and if success, I'll tell you.
Reply
#95

So, I tried.
But have problem - when compile, VC++ "Cannot open include file: 'sampgdk/a_samp-decl.h'"
I read, that cmake would help with that, but I didn't work with cmake (and have no idea, what "a_samp-decl.h" should contain).
Can someone help?
Reply
#96

cmake generates that files automaticly. just do what gdk's readme says.
Reply
#97

I am also trying to work with this nice plugin because of the nice overview and that my php skills are much higher than pawno. It is very easy and nice to do with but I still have problems with some functions like the timer. Here is an example:

PHP код:
Event::on('PlayerEnterVehicle', function($player$vehicle){
    if(
$vehicle->getModel($player) == '462'){
            
$player->sendClientMessage(COLOR_GREY"[Info] You can rent this scooter for $50. Type: /rent");
            
Timer::create(function() {
                
$player->freeze($player);
            }, 
1000false); 
    }
}); 
I get this error:
Quote:

Fatal error: Call to a member function freeze() on a non-object

Without the timer-function I will get freezed directly. I tried already everything but without success. I hope someone can help me with this.

Thank you, best regards from germany.

//EDIT: Has already anyone included the mysql extension? My tries failed hard... Thanks.

//EDIT2: Hmm, so much problems..

I tried to move an object:

PHP код:
Event::on('GameModeInit', function() {
    
$lspdgate Object::create(9861326.7, -1331.714.3600270);
});
CommandText::register('/open', function($player$object){
    
$object->move(00101.00); // Where to add the object-id variable $lspdgate?
    
$player->sendClientMessage(COLOR_GREY"[Info] The gate opens...");
}); 
But where I can define the object-id in the move function? I already checked the object.php file:

PHP код:
public function move($x$y$z$speed$rotX = -1000.0$rotY = -1000.0$rotZ = -1000.0// Here isnt an variable for the object-id... ?!
    
{
        return 
MoveObject($this->id$x$y$z$speed$rotX$rotY$rotZ);
    } 
The same problems I have with pickups. There isnt an variable for the defined pickup. Thank you for your help!
Reply
#98

nice, thanks for update

EDIT:

I've started writing new framework for SAMP PHP, it can be forked HERE.
Point is to create easier way to update and get data about certain thing (e.g player, object, vehicle).
As I started developing today, there is just coverage for some of player function (name, position, rotation, ammo etc...)
Reply
#99

Quote:
Originally Posted by ProSpeed
Посмотреть сообщение
Anonymous function has its scope, you can pass variables using "use" construct.
PHP код:
Timer::create(function() use ($player){
    
$player->freeze();
}, 
1000false); 
More info on http://php.net/manual/en/functions.anonymous.php
I wasn't aware of this even. Thanks =)
Reply

Код:
I'm not sure, but I think this is new PHP 5.6 feature.
But still, it is very useful :)
My bad, it looks like its available in php 5.4
Reply


Forum Jump:


Users browsing this thread: 8 Guest(s)