• Welcome to Vice City Multiplayer.
 

Squirrel

Started by Javi, February 07, 2010, 09:40:20 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Javi

So I keep wondering why developers care about adding Pawn to their new releases, or even improving mIRC when we all know it's a little laggy if you don't make a good use of it. Haven't you heard of Squirrel? It's pretty much faster, easier, and shorter; I could convert a 1000 lines Pawn script in Squirrel with... hmmm 400 lines? Squirrel has much more functions than mIRC and Pawn, and can work along with ini, hash, SQLite and XML. In fact, GTA IV:MP is using Squirrel. And we already have a Squirrel Wiki with all the necessary info, including some nice scripting examples. There's already an unofficial Squirrel VC:MP server.

j-king


thebest12


Force

* Force agrees as well


// Squirrel vs Pawn '/c heal' command


//////////////////////////////
///////// VC:MP Pawn /////////
//////////////////////////////

#include <a_vcmp>
#include <core>
#include <float>

#define INACTIVE_PLAYER_ID 255

public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
new tmp[256];
new szMsg[256];
new idx, newvar;
cmd = strtok(cmdtext, idx);

if (strcmp(cmd, "heal", true) == 0)
{
tmp = strtok(cmdtext, idx);
if (!strlen(tmp)) { newvar = playerid; }
else { newvar = FindPlayerIDFromString(tmp); }
if (newvar == INACTIVE_PLAYER_ID) { return 1; }
if (IsPlayerInAnyVehicle(newvar)) {
SetVehicleHealth(GetPlayerVehicleID(newvar),1000.0);
SetPlayerHealth(newvar,100.0);
} else {
SetPlayerHealth(newvar,100.0);
}
return 1;
}

return 0;
}

public FindPlayerIDFromString(string[])
{// for determining player id from a string  -bakasan
new szMsg[256];
new player = INACTIVE_PLAYER_ID;
new p = 0;
while (p < MAX_PLAYERS) { if (strfind(gPlayers[p],string,true) != -1) { player=p;break; } p++; }
if (player == INACTIVE_PLAYER_ID) {// string didnt match so check if it can be an id
if ((strlen(string) > 2) || (isnumeric(string) == 0)) {
format(szMsg,sizeof(szMsg),"Unable to find %s.",string);
SendClientMessageToAll(COLOR_GREY, szMsg);
return INACTIVE_PLAYER_ID;
}
player = strval(string);// string is numeric and not more than 2 digits
}
if (!IsPlayerConnected(player)) {
format(szMsg,sizeof(szMsg),"Invalid ID %d.",player);
SendClientMessageToAll(COLOR_GREY, szMsg);
return INACTIVE_PLAYER_ID;
}
return player;// valid id found
}



//////////////////////////////
/////// VC:MP Squirrel ///////
//////////////////////////////

function onPlayerCommand( player, cmd, text )
{
if ( cmd == "heal" )
{
if ( text )
{
local plr = FindPlayer( text.tointeger() );

if ( plr )
{
if ( plr.Vehicle ) plr.Vehicle.Health = 1000.0;
plr.Health = 100;
}
else Message( "Invalid ID " + text );
}
}
}

thijn

Although i've never scripted in squirrel i agree to this aswell.


Jc18

Quote from: thijn on February 07, 2010, 10:40:31 PM
Although i've never scripted in squirrel i agree to this aswell.


same :DDDDDDDDD


Boss

You don't really understand what you're talking about, do you?

Quote from: Forze on February 07, 2010, 09:40:20 PM
So I keep wondering why developers care about adding Pawn to their new releases
They're not "adding pawn" (which is pretty added already), but rather add the server functionality activated by specific pawn functions (which they implement too).

Quote from: Forze on February 07, 2010, 09:40:20 PM
or even improving mIRC
Mrc scripting haven't been improved since 0.3z.

Quote from: Forze on February 07, 2010, 09:40:20 PM
when we all know it's a little laggy
Some samples of pawn being laggy maybe? I've got a 20000 lines script back in sa-mp with an extensive use of file-reading/writing and I don't remember it making any witnessable delays. Check your "laggy" script (if you have one) for unoptimized arrays and loops.

Quote from: Forze on February 07, 2010, 09:40:20 PM
It's pretty much faster, easier, and shorter
Already commented on 1st and 2nd is not neccessary a result of 3rd.

Quote from: Forze on February 07, 2010, 09:40:20 PM
I could convert a 1000 lines Pawn script in Squirrel with... hmmm 400 lines?
Looking forward to seing it. ;)

Quote from: Forze on February 07, 2010, 09:40:20 PM
Squirrel has much more functions than mIRC and Pawn
Functions entirely depend on what devs implement. They make a required feature in server first and implement a function for calling it in one of the integrated scripting languages (mrc/pawn/sq) second.

Quote from: Forze on February 07, 2010, 09:40:20 PM
and can work along with ini
Pawn's OnGameModeInit replaces ini entirely. What's your point?

Quote from: Forze on February 07, 2010, 09:40:20 PM
hash
Huh?

Quote from: Forze on February 07, 2010, 09:40:20 PM
SQLite and XML
These can be achieved in pawn with the help of plugins like it was done in sa-mp.

Quote from: Forze on February 07, 2010, 09:40:20 PM
In fact, GTA IV:MP is using Squirrel.
And SA-MP uses pawn. While MTA:SA (which is currently the most decent GTA MP imo) uses lua. What's your point?

Quote from: Forze on February 07, 2010, 09:40:20 PM
And we already have a Squirrel Wiki with all the necessary info, including some nice scripting examples.
As I already stated, it is devs to decide the syntax of the functions to call server's features. So it will only be useful if they decide to reproduce your syntax.

Quote from: Forze on February 07, 2010, 09:40:20 PM
There's already an unofficial Squirrel VC:MP server.
There's already sobeit for VC. What's your point again?

Anyway, not meaning to be offensive, but I'm just trying to explain that integrating a new scripting language is rather bothersome, especially if you want it to be "short and easy" which is achieved through making extra build-in functions in server. It is not me to decide, but I do not think that SQ is likely to be implemented in 0.4 since pawn have been out for just a while.


2 Force:

// Squirrel vs Pawn '/c heal' command

//////////////////////////////
///////// VC:MP Pawn /////////
//////////////////////////////

#include <a_vcmp>
#include <util> // FindPlayerIDFromString and other util functions here
public OnPlayerCommandText(playerid, cmdtext[]){
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
if (strcmp(cmd, "heal", true) == 0){
cmd = strtok(cmdtext, idx);
if (!strlen(cmd)) idx = playerid;
else idx = FindPlayerIDFromString(cmd);
if (idx == INVALID_PLAYER_ID) return 1;
if (IsPlayerInAnyVehicle(idx)) SetVehicleHealth(GetPlayerVehicleID(idx),1000.0);
SetPlayerHealth(idx,100.0);
}
return 1;
}

//////////////////////////////
/////// VC:MP Squirrel ///////
//////////////////////////////

function onPlayerCommand( player, cmd, text ){
if ( cmd == "heal" ) {
if ( text ) {
local plr = FindPlayer( text.tointeger() );
if ( plr ) {
if ( plr.Vehicle ) plr.Vehicle.Health = 1000.0;
plr.Health = 100;
}
else Message( "Invalid ID " + text );
}
}
}

Pawn 15 lines (2 of which are includes), SQ 12. Not such a big difference. Sorry, but if you can't optimize scripts it's not devs' fault. :s

Sephiroth


Force

Quote from: Boss on February 07, 2010, 10:42:37 PM
2 Force:

// Squirrel vs Pawn '/c heal' command

//////////////////////////////
///////// VC:MP Pawn /////////
//////////////////////////////

#include <a_vcmp>
#include <util> // FindPlayerIDFromString and other util functions here
public OnPlayerCommandText(playerid, cmdtext[]){
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
if (strcmp(cmd, "heal", true) == 0){
cmd = strtok(cmdtext, idx);
if (!strlen(cmd)) idx = playerid;
else idx = FindPlayerIDFromString(cmd);
if (idx == INVALID_PLAYER_ID) return 1;
if (IsPlayerInAnyVehicle(idx)) SetVehicleHealth(GetPlayerVehicleID(idx),1000.0);
SetPlayerHealth(idx,100.0);
}
return 1;
}

//////////////////////////////
/////// VC:MP Squirrel ///////
//////////////////////////////

function onPlayerCommand( player, cmd, text ){
if ( cmd == "heal" ) {
if ( text ) {
local plr = FindPlayer( text.tointeger() );
if ( plr ) {
if ( plr.Vehicle ) plr.Vehicle.Health = 1000.0;
plr.Health = 100;
}
else Message( "Invalid ID " + text );
}
}
}

Pawn 15 lines (2 of which are includes), SQ 12. Not such a big difference. Sorry, but if you can't optimize scripts it's not devs' fault. :s

That was a heal command that the developers provided with the server not mine.

If you count the function to find the playerID it's a lot longer than Squirrel, and looks horrible to read.

And wow, you did a good job of making an easy to read language, look hard to read. You really messed around with the Squirrel example.

Boss

Quote from: Sephiroth on February 07, 2010, 11:00:55 PM
http://en.wikipedia.org/wiki/Hash_table 

<3
May I see its usage in VC-MP please?

Quote from: Force on February 07, 2010, 11:02:32 PM
That was a heal command that the developers provided with the server not mine.
Well, yeah, the default mode is actually pretty unoptimized (it does even have two extra includes which are already included in a_vcmp :o). I'm working on a more optimized one.

Quote from: Force on February 07, 2010, 11:02:32 PM
If you count the function to find the playerID it's a lot longer than Squirrel, and looks horrible to read.
You can put all those "horrible functions" in a separate include and forget about them. Actually, SQ does the same, only it puts these functions not in includes, but rather straight into server (making them unchangable). Why didn't VU devs put their function for comparison too? ^^

Quote from: Force on February 07, 2010, 11:02:32 PM
And wow, you did a good job of making an easy to read language, look hard to read. You really messed around with the Squirrel example.
What's wrong with deleting some extra useless "\n"? :s

Javi

Quote from: Boss on February 07, 2010, 10:42:37 PM
Quote from: Forze on February 07, 2010, 09:40:20 PM
So I keep wondering why developers care about adding Pawn to their new releases
They're not "adding pawn" (which is pretty added already), but rather add the server functionality activated by specific pawn functions (which they implement too).
Oh well, yeah whatever, my point is suggesting to add Squirrel to VC:MP officially.

Quote
Quote from: Forze on February 07, 2010, 09:40:20 PM
or even improving mIRC
Mrc scripting haven't been improved since 0.3z.
Same as my first reply.

Quote
Quote from: Forze on February 07, 2010, 09:40:20 PM
when we all know it's a little laggy
Some samples of pawn being laggy maybe? I've got a 20000 lines script back in sa-mp with an extensive use of file-reading/writing and I don't remember it making any witnessable delays. Check your "laggy" script (if you have one) for unoptimized arrays and loops.
PsySQLite lags sometimes, same as GUS; The best use of mIRC is RustySpoon. Squirrel's deninately much faster.

Quote
Quote from: Forze on February 07, 2010, 09:40:20 PM
It's pretty much faster, easier, and shorter
Already commented on 1st and 2nd is not neccessary a result of 3rd.
So you're agreeing it's faster, easier and shorter then?

Quote
Quote from: Forze on February 07, 2010, 09:40:20 PM
I could convert a 1000 lines Pawn script in Squirrel with... hmmm 400 lines?
Looking forward to seing it. ;)
Nah, I'm not working with Pawn since Squirrel's much better  ;)

Quote
Quote from: Forze on February 07, 2010, 09:40:20 PM
Squirrel has much more functions than mIRC and Pawn
Functions entirely depend on what devs implement. They make a required feature in server first and implement a function for calling it in one of the integrated scripting languages (mrc/pawn/sq) second.
That was not what I meant, I was trying to say how Squirrel servers has much more functions than any Pawn / mIRC script, just because they are easier to make :)

Quote
Quote from: Forze on February 07, 2010, 09:40:20 PM
and can work along with ini
Pawn's OnGameModeInit replaces ini entirely. What's your point?
Oh yeah true that, +1 for Pawn, +5 for Squirrel.

Quote
Quote from: Forze on February 07, 2010, 09:40:20 PM
hash
Huh?
Sephiroth already answered this one.

Quote
Quote from: Forze on February 07, 2010, 09:40:20 PM
SQLite and XML
These can be achieved in pawn with the help of plugins like it was done in sa-mp.
I was just saying how much formats Squirrel can read.

Quote
Quote from: Forze on February 07, 2010, 09:40:20 PM
In fact, GTA IV:MP is using Squirrel.
And SA-MP uses pawn. While MTA:SA (which is currently the most decent GTA MP imo) uses lua. What's your point?
My point is GTA IV is the newest one, and they chose Squirrel, huh why did they choose Squirrel?  :)

Quote
Quote from: Forze on February 07, 2010, 09:40:20 PM
And we already have a Squirrel Wiki with all the necessary info, including some nice scripting examples.
As I already stated, it is devs to decide the syntax of the functions to call server's features. So it will only be useful if they decide to reproduce your syntax.
If they do or not, the wiki's still there, and it definately helped me.

Quote
Quote from: Forze on February 07, 2010, 09:40:20 PM
There's already an unofficial Squirrel VC:MP server.
There's already sobeit for VC. What's your point again?
Suggesting to add Squirrel to VC:MP, as I said before.


Javi

#11
Sorry for double posting but:

Quote from: Boss on February 07, 2010, 11:09:45 PM
Quote from: Sephiroth on February 07, 2010, 11:00:55 PM
http://en.wikipedia.org/wiki/Hash_table  

<3
May I see its usage in VC-MP please?
A hash is simply faster than an ini.


For example, Squirrel is more object orientated, has classes which are pretty useful, and has pretty fast mathematical stuff and native floats. Could also mention JIT debugging (Just In Time) which you can debug scripts in real time, and the ability to execute script code at runtime. Pawn's string processing slows down the longer the size of the string is apparently.

Boss

#12
Quote from: Forze on February 07, 2010, 11:14:38 PM
PsySQLite lags sometimes, same as GUS; The best use of mIRC is RustySpoon. Squirrel's deninately much faster.
Aren't they mrc scripts? I thought we're comparing pawn and SQ here. :s

Quote from: Forze on February 07, 2010, 11:14:38 PM
So you're agreeing it's faster, easier and shorter then?
No. You didn't prove that it's faster, I already proved that it's shorter because of the "horrible functions" being implemented straight into the server rather than includes. And, if it is easier, only because of it being "shorter". Though I DO agree that players/vehicles behaving like classes is nice.

Quote from: Forze on February 07, 2010, 11:14:38 PM
Nah, I'm not working with Pawn since Squirrel's much better  ;)
STATEMENT FAILED THEN.

Quote from: Forze on February 07, 2010, 11:14:38 PM
That was not what I meant, I was trying to say how Squirrel servers has much more functions than any Pawn / mIRC script, just because they are easier to make :)
I don't know which language is easier to integrate, but I hope your statement comes from one of VU devs.

Quote from: Forze on February 07, 2010, 11:14:38 PM
Oh yeah true that, +1 for Pawn, +5 for Squirrel.
Um... excuse me?

Quote from: Forze on February 07, 2010, 11:14:38 PM
My point is GTA IV is the newest one, and they chose Squirrel, huh why did they choose Squirrel?  :)
GTA:SA was made by people having full R* support. Huh, why would people knowing the best way to exploit GTA's functionality choose lua?

Quote from: Forze on February 07, 2010, 11:14:38 PM
Suggesting to add Squirrel to VC:MP, as I said before.
Ok, some people added SQ to VC-MP's server. Other people don't have the time to add it. Your point still fails.




Quote from: Forze on February 07, 2010, 11:17:29 PM
A hash is simply faster than an ini.
... with the latter being completely substituded by pawn's OnGameModeInit. I think you're still comparing to mrc.

Quote from: Forze on February 07, 2010, 11:17:29 PM
Squirrel is more object orientated, has classes which are pretty useful
Agreed here.

Quote from: Forze on February 07, 2010, 11:17:29 PM
and has pretty fast mathematical stuff
Speed tests?

Quote from: Forze on February 07, 2010, 11:17:29 PM
Could also mention JIT debugging (Just In Time) which you can debug scripts in real time
How exactly do you want to properly debug a script without even entering the game? :s

Quote from: Forze on February 07, 2010, 11:17:29 PM
Pawn's string processing slows down the longer the size of the string is apparently.
Pawn's strings are fuxxed, agreed here too. Their size should be dynamic rather than pre-determined.

[AoD]NC

I dont have time to read this nice-looking-conversation but i agree.
SQUIRREL > PAWN
<3

Javi

#14
Quote from: Boss on February 07, 2010, 11:25:49 PM
Quote from: Forze on February 07, 2010, 11:14:38 PM
PsySQLite lags sometimes, same as GUS; The best use of mIRC is RustySpoon. Squirrel's deninately much faster.
Aren't they mrc scripts? I thought we're comparing pawn and SQ here. :s
mIRC and Pawn in general  :)

Quote
Quote from: Forze on February 07, 2010, 11:14:38 PM
So you're agreeing it's faster, easier and shorter then?
No. You didn't prove that it's faster, I already proved that it's shorter because of the "horrible functions" being implemented straight into the server rather than includes. And, if it is easier, only because of it being "shorter". Though I DO agree that players/vehicles behaving like classes is nice.
I still like Squirrel better.

Quote
Quote from: Forze on February 07, 2010, 11:14:38 PM
Nah, I'm not working with Pawn since Squirrel's much better  ;)
STATEMENT FAILED THEN.
Statement didn't fail at all.

Quote
Quote from: Forze on February 07, 2010, 11:14:38 PM
That was not what I meant, I was trying to say how Squirrel servers has much more functions than any Pawn / mIRC script, just because they are easier to make :)
I don't know which language is easier to integrate, but I hope your statement comes from one of VU devs.
Me neither, Squirrel's still better IMO.

Quote
Quote from: Forze on February 07, 2010, 11:14:38 PM
Oh yeah true that, +1 for Pawn, +5 for Squirrel.
Um... excuse me?
Not literally speaking of course, I meant Squirrel has more scripting chances than Pawn.

Quote
Quote from: Forze on February 07, 2010, 11:14:38 PM
My point is GTA IV is the newest one, and they chose Squirrel, huh why did they choose Squirrel?  :)
GTA:SA was made by people having full R* support. Huh, why would people knowing the best way to exploit GTA's functionality choose lua?
MTA doesn't have full R* support, people have different preferences

Quote
Quote from: Forze on February 07, 2010, 11:14:38 PM
Suggesting to add Squirrel to VC:MP, as I said before.
Ok, some people added SQ to VC-MP's server. Other people don't have the time to add it. Your point still fails.
Nah, it doesn't. Seriously why are you attacking my suggestion like this? Looks like I'm not free to share my opinion.

Quote
Quote from: Forze on February 07, 2010, 11:14:38 PM
A hash is simply faster than an ini.
... with the latter being completely substituded by pawn's OnGameModeInit. I think you're still comparing to mrc.
Oh well, I never said Pawn's OnGameModeInit's worse than Squirrel's method, in fact it's better.


I've got to go now, I hope I get some constructive replies when I come back  :)