• Welcome to Vice City Multiplayer.
 
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - stormeus

#46
ShowRoom (pawn) / Re: SetVehiclePos?!?!
April 21, 2011, 09:25:53 PM
Nice bump; this thread hasn't been replied to in months. ::)
Also:
Quote from: sseebbyy on April 21, 2011, 09:41:40 AM
This is Solution  ;D

Credits: By Tato


SetVehiclePos(GetPlayerVehicleID(playerid),X,Y,Z,Angle);
SetVehiclePos(SetVehiclePos(GetPlayerVehicleID(playerid),X,Y,Z,Angle);


He said SetVehiclePos doesn't work, so this code wouldn't work anyways.
#47
Tutorials / Re: Started A Video Tutorial BY BIG[H]
April 21, 2011, 09:22:21 PM
I agree with Skirmant. And to play the role of the critical asshole a little bit, the tutorial doesn't explain what OnPlayerCommandText is or what it does. It doesn't explain what the code being typed does, and it doesn't explain how it all comes together. For a beginner tutorial, you should try starting out with something like a small introduction to what programming is and getting into the real basics, like what variables and constants are and how to use them.
#48
mIRC/pawn Scripting / Re: MY Scripts!!!!
April 21, 2011, 07:44:52 PM
Quite an odd error. You might be trying to use an unimplemented function (function that wasn't actually made), or the gamemode isn't in the gamemodes folder. My crystal ball also tells me you could be missing #include <dini>, but that's a wild guess.
#49
mIRC/pawn Scripting / Re: Drift Point = Money ?
April 20, 2011, 10:24:07 PM
Like an insane stunt bonus? I don't think that can be done with scripts.
#50
mIRC/pawn Scripting / Re: I need help ... Please
April 20, 2011, 09:23:52 PM
Quote from: locday123 on April 20, 2011, 03:51:11 PM
Ok....I want..Let me...Thanks

???
So you're going to script it yourself?
#51
Script Showroom / Re: How to made Scripts
April 20, 2011, 09:22:18 PM
Quote from: asad3man on April 20, 2011, 01:53:54 PM
what is difference bween pawno and squirrel and aso tell me how to publish server that shows on internet

1. Pawn is made for Pawn servers. Squirrel is made for Squirrel servers. If you downloaded a server from the home page, you have a Pawn server.
2. http://forum.vicecitymultiplayer.com/index.php?topic=2389.0
#52
Support / Re: gangwar
April 20, 2011, 06:11:21 AM
You might've been banned from the server if you're getting kicked automatically. Try contacting one of the admins from the server.
#53
mIRC/pawn Scripting / Re: I need help ... Please
April 20, 2011, 05:47:54 AM
Be more specific. Pawn or mIRC? Do you want the lottery system to be one where you buy a ticket and a ticket is randomly selected? How often do you want the lottery to run?
#54
Support / Re: VC-MP Wiki
April 19, 2011, 10:33:54 PM
And now to bump a four-month-old topic (which is already stickied), I'm starting an overhaul on the wiki. I'm hoping to document most of the undocumented functions on Boss's wiki, and making the articles a little more readable. If anyone wants to help out, make a wiki account and send me a PM. (Or do what you want :P)

EDIT: a_vcmp.inc > Util completely documented.
EDIT: time.inc completely documented.
#55
I see the first topic got locked. Anyways, rulk, I'm glad to see you appreciate the amount of work I put into the script and the comments. I like to comment my code so that if I ever release a snippet or gamemode, other people can use it as a reference to learn from. Like you said, it might not be the speediest, but I'll learn with time, so once again, thanks! :)
#56
Script Showroom / Re: How to made Scripts
April 19, 2011, 08:38:31 PM
If you want to learn Squirrel or mIRC, VRocker's wiki is a great reference for learning both of them and is well documented.
http://liberty-unleashed.co.uk/VCWiki/Main_Page VRocker's Wiki

Or if you want to learn Pawn, you can use either the official VCMP wiki or the SAMP wiki (for learning about Pawn in general ONLY).
http://www.compuphase.com/pawn/pawn.htm#DOWNLOAD_DOCS Official Pawn Documentation
http://famp.ru/wiki/Main_Page VC:MP Wiki
http://wiki.sa-mp.com/wiki/Scripting_Basics SA:MP Wiki
#57
mIRC/pawn Scripting / Re: Set World Bounds in Pawno?
April 18, 2011, 11:48:57 PM
You can't exactly set a world boundary. However, you could restrict them to one area of the map. For example, if PlayerInfo[playerid][Restricted] is set to 1 and the user's area is outside of a set box, teleport them back into that box.
#58
ShowRoom (pawn) / Top Three Players (by K/D ratio)
April 18, 2011, 09:04:24 PM
This command (/c topoverall) was written for a help topic and is being moved to the Pawn showroom for anyone looking for it in the future. This command will get the three best players according to kill/death ratio.

Warning
As more people play on your server, this command will become more resource intensive.

Note
This command was made based off of a GUPS script. It likely will not work on a blank gamemode and the instructions might not be the same.

Screenshot



Include:

#include <dini>
#include <float>


Put this code in OnPlayerCommandText():

// Show the best players overall
else if(strcmp(cmd, "topoverall", true) == 0)
{
// Declare some variables that we'll need
new topUser1[2][128],
topUser2[2][128],
topUser3[2][128],
userFile[64],
Float:deaths,
Float:kills,
Float:ratio,
sRatio[10],
nick[128],
i,
j;

// Set the default ratios for our top users
topUser1[1] = "0.00";
topUser2[1] = "0.00";
topUser3[1] = "0.00";

// Get the total number of known users.
j = dini_Int("/AllUsers.ini", "Index");

// Iterate through all known users
for(i = 1; i < j + 1; i++)
{
// Get this person's nickname.
nick = dini_Get("/AllUsers.ini", IntToStr(i));

// Find this user's file.
format
(
// String formatting
userFile,
sizeof(userFile),
"/Users/%s.ini",

// Variables, respectively
nick
);

// Get their kills and deaths.
kills  = dini_Int(userFile, "Kills");
deaths = dini_Int(userFile, "Deaths");

// Now find their K/D ratio.
ratio = floatdiv(kills, deaths);

// Is this ratio better than the current first-place holder's?
if(ratio > floatstr(topUser1[1]))
{
// Is there a person in first place?
if(floatstr(topUser1[1]) > 0)
{
// Is there a person in second place?
if(floatstr(topUser2[1]) > 0)
{
// Move the previous second place winner to third place
topUser3 = topUser2;

// Move the previous first place winner to second place
topUser2 = topUser1;
}
// Nope
else
{
// Move the previous first place winner to second place
topUser2 = topUser1;
}
}

// Set them as first-place.
topUser1[0] = nick;

// Convert their ratio to a string
format
(
// String formatting
sRatio,
sizeof(sRatio),
"%f",

// Variables, respectively
ratio
);

// Set their ratio as the ratio string
topUser1[1] = sRatio;

// Done here.
continue;
}
// No, but is it better than second-place?
else if(ratio > floatstr(topUser2[1]))
{
// Is there a person in second place?
if(floatstr(topUser2[1]) > 0)
{
// Move the previous second place winner to third place
topUser3 = topUser2;
}

// Set them as second-place.
topUser2[0] = nick;

// Convert their ratio to a string
format
(
// String formatting
sRatio,
sizeof(sRatio),
"%f",

// Variables, respectively
ratio
);

// Set their ratio as the ratio string
topUser2[1] = sRatio;

// Done here.
continue;
}
// No, but is it better than third-place?
else if(ratio > floatstr(topUser3[1]))
{
// Yes. Set them as third-place.
topUser3[0] = nick;

// Convert their ratio to a string
format
(
// String formatting
sRatio,
sizeof(sRatio),
"%f",

// Variables, respectively
ratio
);

// Set their ratio as the ratio string
topUser3[1] = sRatio;

// Done here.
continue;
}
// They did not rank in the Top 3.
else
{
continue;
}
}

// Start posting the top three
SendClientMessageToAll(COLOR_YELLOW, "** Top Three Players **");

// Format a message string for first place.
format
(
// String formatting
szMsg,
sizeof(szMsg),
"1. %s - %.2f",

// Variables, respectively
topUser1[0],
floatstr(topUser1[1])
);

// Send to everyone
SendClientMessageToAll(COLOR_YELLOW, szMsg);

// Format a message for second place.
format
(
// String formatting
szMsg,
sizeof(szMsg),
"2. %s - %.2f",

// Variables, respectively
topUser2[0],
floatstr(topUser2[1])
);

// Send to everyone
SendClientMessageToAll(COLOR_YELLOW, szMsg);

// Format a message for third place.
format
(
// String formatting
szMsg,
sizeof(szMsg),
"3. %s - %.2f",

// Variables, respectively
topUser3[0],
floatstr(topUser3[1])
);

// Send to everyone
SendClientMessageToAll(COLOR_YELLOW, szMsg);

// Done.
return 1;
}


Put this code in OnGameModeInit():

// Create the all users INI if it does not exist
if(!dini_Exists("/AllUsers.ini"))
{
    // Create it with an index of 0 for no users
    dini_Create("/AllUsers.ini");
    dini_IntSet("/AllUsers.ini", "Index", 0);
}


Put this code in OnPlayerConnect() under if(dini_Exists(file)):

// Add them to the All Users INI if they aren't in it
new j = dini_Int("/AllUsers.ini", "Index"),
i,
found = 0,
result[128];

// Iterate through all users
for(i = 1; i < j + 1; i++)
{
// Get this user's nick.
result = dini_Get("/AllUsers.ini", IntToStr(i));

// This is them.
if(strcmp(result, gPlayers[playerid], true) == 0)
{
// Found them!
found = 1;

// Stop
break;
}
}

// They're not there.
if(found == 0)
{
// Increment the index.
j++;

// Add them to the index.
dini_Set("/AllUsers.ini", IntToStr(j), gPlayers[playerid]);

// Reset the index to variable "j"
dini_IntSet("/AllUsers.ini", "Index", j);
}
#59
mIRC/pawn Scripting / Re: Help !Top
April 18, 2011, 08:58:40 PM
All users overall
(warning: this will become more resource intensive as more users sign up)

Put this code in OnPlayerCommandText():

// Show the best players overall
else if(strcmp(cmd, "topoverall", true) == 0)
{
// Declare some variables that we'll need
new topUser1[2][128],
topUser2[2][128],
topUser3[2][128],
userFile[64],
Float:deaths,
Float:kills,
Float:ratio,
sRatio[10],
nick[128],
i,
j;

// Set the default ratios for our top users
topUser1[1] = "0.00";
topUser2[1] = "0.00";
topUser3[1] = "0.00";

// Get the total number of known users.
j = dini_Int("/AllUsers.ini", "Index");

// Iterate through all known users
for(i = 1; i < j + 1; i++)
{
// Get this person's nickname.
nick = dini_Get("/AllUsers.ini", IntToStr(i));

// Find this user's file.
format
(
// String formatting
userFile,
sizeof(userFile),
"/Users/%s.ini",

// Variables, respectively
nick
);

// Get their kills and deaths.
kills  = dini_Int(userFile, "Kills");
deaths = dini_Int(userFile, "Deaths");

// Now find their K/D ratio.
ratio = floatdiv(kills, deaths);

// Is this ratio better than the current first-place holder's?
if(ratio > floatstr(topUser1[1]))
{
// Is there a person in first place?
if(floatstr(topUser1[1]) > 0)
{
// Is there a person in second place?
if(floatstr(topUser2[1]) > 0)
{
// Move the previous second place winner to third place
topUser3 = topUser2;

// Move the previous first place winner to second place
topUser2 = topUser1;
}
// Nope
else
{
// Move the previous first place winner to second place
topUser2 = topUser1;
}
}

// Set them as first-place.
topUser1[0] = nick;

// Convert their ratio to a string
format
(
// String formatting
sRatio,
sizeof(sRatio),
"%f",

// Variables, respectively
ratio
);

// Set their ratio as the ratio string
topUser1[1] = sRatio;

// Done here.
continue;
}
// No, but is it better than second-place?
else if(ratio > floatstr(topUser2[1]))
{
// Is there a person in second place?
if(floatstr(topUser2[1]) > 0)
{
// Move the previous second place winner to third place
topUser3 = topUser2;
}

// Set them as second-place.
topUser2[0] = nick;

// Convert their ratio to a string
format
(
// String formatting
sRatio,
sizeof(sRatio),
"%f",

// Variables, respectively
ratio
);

// Set their ratio as the ratio string
topUser2[1] = sRatio;

// Done here.
continue;
}
// No, but is it better than third-place?
else if(ratio > floatstr(topUser3[1]))
{
// Yes. Set them as third-place.
topUser3[0] = nick;

// Convert their ratio to a string
format
(
// String formatting
sRatio,
sizeof(sRatio),
"%f",

// Variables, respectively
ratio
);

// Set their ratio as the ratio string
topUser3[1] = sRatio;

// Done here.
continue;
}
// They did not rank in the Top 3.
else
{
continue;
}
}

// Start posting the top three
SendClientMessageToAll(COLOR_YELLOW, "** Top Three Players **");

// Format a message string for first place.
format
(
// String formatting
szMsg,
sizeof(szMsg),
"1. %s - %.2f",

// Variables, respectively
topUser1[0],
floatstr(topUser1[1])
);

// Send to everyone
SendClientMessageToAll(COLOR_YELLOW, szMsg);

// Format a message for second place.
format
(
// String formatting
szMsg,
sizeof(szMsg),
"2. %s - %.2f",

// Variables, respectively
topUser2[0],
floatstr(topUser2[1])
);

// Send to everyone
SendClientMessageToAll(COLOR_YELLOW, szMsg);

// Format a message for third place.
format
(
// String formatting
szMsg,
sizeof(szMsg),
"3. %s - %.2f",

// Variables, respectively
topUser3[0],
floatstr(topUser3[1])
);

// Send to everyone
SendClientMessageToAll(COLOR_YELLOW, szMsg);

// Done.
return 1;
}


Put this code in OnGameModeInit():

// Create the all users INI if it does not exist
if(!dini_Exists("/AllUsers.ini"))
{
    // Create it with an index of 0 for no users
    dini_Create("/AllUsers.ini");
    dini_IntSet("/AllUsers.ini", "Index", 0);
}


Put this code in OnPlayerConnect() under if(dini_Exists(file)):

// Add them to the All Users INI if they aren't in it
new j = dini_Int("/AllUsers.ini", "Index"),
i,
found = 0,
result[128];

// Iterate through all users
for(i = 1; i < j + 1; i++)
{
// Get this user's nick.
result = dini_Get("/AllUsers.ini", IntToStr(i));

// This is them.
if(strcmp(result, gPlayers[playerid], true) == 0)
{
// Found them!
found = 1;

// Stop
break;
}
}

// They're not there.
if(found == 0)
{
// Increment the index.
j++;

// Add them to the index.
dini_Set("/AllUsers.ini", IntToStr(j), gPlayers[playerid]);

// Reset the index to variable "j"
dini_IntSet("/AllUsers.ini", "Index", j);
}


Screenshot
#60
ShowRoom (pawn) / phPSA (rev1)
April 17, 2011, 08:14:34 AM
phPSA is a project I started due to the inactivity of PSA (the Pawn Supporting Application) and its incompatibility with Linux servers. For guaranteed cross-compatibility and to let you guys look at the source easily, phPSA is written in PHP. Since this is a new project, a few bugs are expected here and there and it may not be as efficient as you'd like it to be, so please, post constructive feedback.

PHP Pawn Supporting Application
phPSA is an external application, extending Pawn's functionality. It communicates with Pawn through text files, allowing PSA to perform a variety of actions normally unavaliable in Pawn. You can think of PSA as a plugin, only external.

Currently phPSA only supports SQL data storage. IRC echo support will be implemented at a later time.

Download
The current phPSA version is Revision 1. You can download it using any of the following links:

The archive includes:




readme.htmHelp and tutorial file
phpsa.phpphPSA script. This is an executable AND the source code.
phpsa.cfgphPSA Configuration

Installation

  • Put the appropriate functions in your script. These functions are written below.
    Quote






    new gColumns[24][128]...Variables used for reading rows from SELECT queries.
    PSAtimer()PSA timer function. Processes activity between phPSA and your gamemode.
    SetTimer("PSAtimer", 200, 1)Activates the phPSA timer function every 200ms repeatedly.
    PerformSQLquery(str[])Performs a regular SQL query.
    OnQueryResult(qid[], str[], index)Called whenever any query is done. Returns the number of rows affected OR 1 on a SELECT query.
    If the query is a SELECT query, the column names are stored in gColumns and the values in gValues.
  • Put phpsa.php and phpsa.cfg in your server's root dir (where vcmp-svr is).
  • Edit phpsa.cfg with your MySQL settings
  • Launch phpsa.php using the PHP runtime.

phPSA REQUIRES PHP to work.

Ubuntu/Debian users can use this command to install PHP:
sudo apt-get install php5

Function Code

PerformSQLquery(str[])
{
// Open a file pointer to SQL input
new File: filex;
filex = fopen("sql_input.psa");

// Perform the query
fwrite(filex, str);

// Close the buffer
fclose(filex);

// Return
return 1;
}

new gColumns[32][24][128],
gValues[32][24][128],
allColumns[24][256],
allValues[2][128];

OnQueryResult(str[], index)
{
// Try to parse it
// If there's an = sign, it's a DINI
if(strfind(str, "=") > 0)
{
   // Declare some variables
   new i, j;
   
   // Find the prefix
   new prefix[4];
format(prefix, sizeof(prefix), "%d=", index);
   
   // Get rid of the "index=" prefix
   strdel(str, 0, strlen(prefix));

// Split according to each column in a row
split(str, allColumns, ',');
   
   // Now read all columns
   for(i = 0; i < 24; i++)
   {
       // Not empty, keep going
       if(strlen(allColumns[i]))
       {
       // Now split the string according to equal signs
       split(allColumns[i], allValues, '=');
       
       // And read all the values
        for(j = 0; j < sizeof(allValues); j++)
       {
           // The column name has to be set
           gColumns[index - 1][i] = allValues[j];
           
            // Increment j again. We only read every two values.
           j++;
           
           // The column value has to be set
           gValues[index - 1][i]  = allValues[j];
       }
       }
// It's empty. There can't possibly be more.
else
{
   // Format a message string
   new szMsg[256];
   format(szMsg, sizeof(szMsg), "Column %s == %s", gColumns[0][0], gValues[0][0]);
   
   // Output the first row's value for the first column
   // Uncomment this if you ever want to debug it
   SendClientMessageToAll(COLOR_YELLOW, szMsg);

   // Break the for loop.
   break;
}
   }
   
   // We're done. Everything went better than expected.
   return 1;
}
// Number of rows affected
else
{
   // Return the number of affected rows as an integer
   return strval(str);
}
}

public PSAtimer() // PSA timer for reading things.
{
// Declare some variables
new cont[2048], str[256], File: filex, index;

// Check if we have SQL output
if(fexist("sql_output.psa"))
{
// Open a pointer to the SQL output
filex = fopen("sql_output.psa");

// The index is 1.
index = 1;

// Read the output
while(fread(filex,cont,sizeof(cont)))
{
   if(strlen(cont))
   {
// Keep reading until we hit the end of the file
while(strfind(cont,"\n")>0)
{
strmid(str,cont,0,strfind(cont,"\n"));
strdel(cont,0,strfind(cont,"\n"));
}

// Call the "OnQueryResult" event
OnQueryResult(str,index);

// Increment the index
index++;
}
}

// Close the pointer
fclose(filex);

// Delete the files for a fresh start next time
fremove("sql_input.psa");
fremove("sql_output.psa");
}
}
stock split(const strsrc[], strdest[][], delimiter)
{
new k, li;
new aNum;
new len;
while(k <= strlen(strsrc))
{
if(strsrc[k] == delimiter || k == strlen(strsrc))
{
len = strmid(strdest[aNum], strsrc, li, k, 128);
strdest[aNum][len] = 0;
li = k+1;
aNum++;
}
k++;
}
return 1;
}


To-Do

  • Implement IRC functions.
  • Convert to SQLite? (Discuss in thread)

Feedback
Suggestions, questions, and bug reports should be posted in this thread.

Version History
Revision 1

  • PSA rewritten in PHP for cross-compatibility
  • Pawn functions written for easy SELECT querying