• 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

Topics - Ettans

#1
ShowRoom (pawn) / [CP] Vehicle array
February 20, 2010, 03:41:37 PM
Here's an array with vehicle names, it's in order so you can use it to get the vehicles model from the name. You can use it to spawn vehicles by typing their name, instead of the model ID etc. You can find the array at the bottom of the post, simply put it near the top of your gamemode, among other defines and variables.


The array:


new vArray[107][] =
{
       {"Landstalker"},
       {"Idaho"},
{"Stinger"},
{"Linerunner"},
{"Perennial"},
{"Sentinel"},
{"Rio"},
{"Firetruck"},
{"Trashmaster"},
{"Stretch"},
{"Manana"},
{"Infernus"},
{"Voodoo"},
{"Pony"},
{"Mule"},
{"Cheetah"},
{"Ambulance"},
{"FBI Washington"},
{"Moonbeam"},
{"Esperanto"},
{"Taxi"},
{"Washington"},
{"Bobcat"},
{"Mr Whoopee"},
{"BF Injection"},
{"Hunter"},
{"Police"},
{"Enforcer"},
{"Securicar"},
{"Banshee"},
{"Predator"},
{"Bus"},
{"Rhino"},
{"Barracks"},
{"Cuban Hermes"},
{"Helicopter"}, // WARNING: Crashes the client if exited
{"Angel"},
{"Coach"},
{"Cabbie"},
{"Stallion"},
{"Rumpo"},
{"RC Bandit"},
{"Romero's Hearse"},
{"Packer"},
{"Sentinel XS"},
{"Admiral"},
{"Squalo"},
{"Sea Sparrow"},
{"Pizza Boy"},
{"Gang Burrito"},
{" "}, // UNKNOWN ID
{" "}, // UNKNOWN ID
{"Speeder"},
{"Reefer"},
{"Tropic"},
{"Flatbed"},
{"Yankee"},
{"Caddy"},
{"Zebra Cab"},
{"Top Fun"},
{"Skimmer"},
{"PCJ 600"},
{"Faggio"},
{"Freeway"},
{"RC Baron"}, // WARNING: Crashes the client if exited
{"RC Raider"}, // WARNING: Crashes the client if exited
{"Glendale"},
{"Oceanic"},
{"Sanchez"},
{"Sparrow"},
{"Patriot"},
{"Love Fist"},
{"Coast Guard"},
{"Dinghy"},
{"Hermes"},
{"Sabre"},
{"Sabre Turbo"},
{"Phoenix"},
{"Walton"},
{"Regina"},
{"Comet"},
{"Deluxo"},
{"Burrito"},
{"Spand Express"},
{"Marquis"},
{"Baggage Handler"},
{"Kaufman Cab"},
{"Maverick"},
{"VCN Maverick"},
{"Rancher"},
{"FBI Rancher"},
{"Virgo"},
{"Greenwood"},
{"Cuban Jetmax"},
{"Hotring Racer 1"},
{"Sandking"},
{"Blista Compact"},
{"Police Maverick"},
{"Benson"},
{"Boxville"},
{"Mesa Grande"},
{"RC Goblin"},
{"Hotring Racer 2"},
{"Hotring Racer 3"},
{"Bloodring Banger 1"},
{"Bloodring Bander 2"},
{"FBI Cheetah"}
};



Example command: !vehicle
Description: Type !vehicle <name> to spawn the vehicle.


/*

new cmd[256],
   string[128],
   idx,
   cmd = strtok(cmdtext, idx);

*/

// Add to OnPlayerText callback and make sure you have the variables shown above present already.

if(strcmp(cmd,"!vehicle",true) == 0)
{
   new Float:x,
       Float:y,
       Float:z,
Float:angle,
vDat,
       pveh[MAX_PLAYERS] = 0;

   vDat = vModelFromName(cmdtext[9]);
   GetPlayerPos(playerid,x,y,z);
   GetPlayerFacingAngle(playerid,angle);

   if(vDat < 130 || vDat > 236)
   {
       SendClientMessage(playerid,COLOR_GREY,"Invalid model ID or name!");
       return 0;
   }

   pveh[playerid] = CreateVehicle(vDat,x,y,z,angle,-1,-1,100);
   PutPlayerInVehicle(playerid,pveh[playerid]);
   format(string,sizeof(string),"Spawned a %s",vArray[vDat - 130]);
   SendClientMessage(playerid,COLOR_GREEN,string);
   return 0;
}



Additional function: vModelFromName
Description: Gets the vehicle model ID from the name, using the array.


vModelFromName(vName[])
{
   for(new i = 0; i < 109; i++)
       if(strfind(vArray[i],vName,true) != -1 )
           return i+130;
   return -1;
}



Pastebin link of array: http://pastebin.com/f3afd52cf
Pastebin link of vModelFromName: http://pastebin.com/f5851c541
Pastebin link of example command: http://pastebin.com/f30444fc6
#2
ShowRoom (pawn) / [CP] Builder commands.
February 20, 2010, 01:31:39 PM
It's just a code-piece of OnPlayerText callback. I only made it because I needed an easy way to change some settings and save raw coordinates, without using the build mode.
Simply replace your OnPlayerText callback with this one, or copy the commands to your own OnPlayerText callback.

Commands


  • !help - Show a list of commands.
  • !slomo <value> - Sets the gamespeed to the given value. If no value is given, it's set to default (100).
  • !gravity <value> - Sets the gravity to the given value. If no value is given, it's set to default (100).
  • !packer - Spawns a Packer at your position and automatically puts you in it.
  • !taxi- Spawns a Taxi at your position and automatically puts you in it.
  • !pcj - Spawns a PCJ600 at your position and automatically puts you in it.
  • !sanchez - Spawns a Sanchez at your position and automatically puts you in it.
  • !fix - Fixes the vehicle you're in.
  • !pos- Shows your current coordinates (x,y,z,angle).
  • !savepos - Saves your current raw coordinates (x,y,z,angle) to savedpos.txt in the /scriptfiles/ folder.

Note: Before using !savepos, make sure you have scriptfiles folder in your server folder, otherwise it'll crash the server.

Example of saved coordinates in savedpos.txt:


346.19,-262.54,35.88,3.11 // x,y,z,angle
444.85,-437.57,10.14,0.04 // x,y,z,angle


Link to code: http://pastebin.com/fbd0d2d4

Currently I'm working on an array with vehicle names and models.
#3
ShowRoom (pawn) / [INC] Some math functions
February 06, 2010, 01:44:21 PM
QuoteMathematical functions

* Written by Ettans ([email protected])
* Last modified 02/07/2010
* If you use this include, please give proper credit.

This include (na_math.inc) is written for SA:MP and VC:MP (PAWN server), adding additional mathematical functions
for any scripter to use. For an example, you can use these functions to add mathematical minigames to your servers and reward
players when they answer correctly.

Note: I'm really looking forward to decent suggestions, as I intend to keep this updated.

Setup:

Extract na_math_include.zip and copy the na_math.inc to your /pawno/includes/ folder. Open your gamemode and add #include <na_math> to the top. You're all done!

Functions:

  • euclid_gcd(a,b);
Description: Determines the greatest common divider of two numbers using Euclid's algorithm

Example usage: euclid_gcd(6,12); // Will return 6
Example usage: euclid_gcd(25,5); // Will return 5

  • euclid_lcm(a,b);
Description: Determines the least common multiple of two numbers using Euclid's algorithm

Example usage: euclid_lcm(4,8); // Will return 8
Example usage: euclid_lcm(12,6); // Will return 12

  • abs(a);
Description: Returns the absolute value of an integer

Example usage: abs(4); // Will return 4
Example usage: abs(-6); // Will return 6

  • exp(Float:num);
Description: Returns the value of E^x, where E is Euler's constant and x is the number passed to it

Example usage: exp(-1); // Will return 0.3678794
Example usage: exp(5); // Will return 148.4131591

  • deg2rad(Float:deg);
Description: Convert a degree to a radian number

Example usage: deg2rad(6); // Will return 0.1047198
Example usage: deg2rad(10); // Will return 0.1745329
Example usage: deg2rad(10.5); // Will return 0.1832596

  • rad2deg(Float:rad);
Description: Convert a radian number to a degree

Example usage: rad2deg(2); // Will return 114.59156
Example usage: rad2deg(5); // Will return 286.4789
Example usage: rad2deg(2.4); // Will return 137.509872

Example commands:

> May need editing, as it's meant for SA:MP.


printf("Euler's constant (1) %f",exp(1));
printf("5 Degrees to radians %f",deg2rad(10));


/*
* Requires you to have string pre-defined somewhere in your script, mostly at the top of OnPlayerCommandText.
* Simply copy these commands to your OnPlayerCommandText callback.
*/

// Greatest common divider
if(strcmp(cmd, "/euclid_gcd", true) == 0)
{
   new val_x1 = strval(cmdtext[12]);
   new val_x2 = strval(cmdtext[14]);
   
   format(string,sizeof(string),"(Greatest common divider) Result: %d",euclid_gcd(val_x1,val_x2));
   SendClientMessage(playerid,0xFFFFFFFF,string);
   return 1;
}

// Least common multiple
if(strcmp(cmd, "/euclid_lcm", true) == 0)
{
   new val1 = strval(cmdtext[12]);
   new val2 = strval(cmdtext[14]);
   
   format(string,sizeof(string),"(Least common multiple) Result: %d",euclid_lcm(val1,val2));
   SendClientMessage(playerid,0xFFFFFFFF,string);
   return 1;
}

// Absolute value
if(strcmp(cmd, "/abs", true) == 0)
{
   new val = strval(cmdtext[9]);
   
   format(string,sizeof(string),"Absolue value: %d",abs(val));
   SendClientMessage(playerid,0xFFFFFFFF,string);
   return 1;
}


Download link of the include: uploadFFS (Contains the include and a Readme document)
#4
Support / Can't change resolution for VC-MP.
January 20, 2010, 02:37:10 PM
Hi! Whenever I join a server, my resolution is always at 640x480x16. Although I have 1680x1050x32 set in GTA:Vice City. Any idea what could cause this?

OS: Windows 7, x32
Newest drivers for my GPU.
#5
Hi. Seems that the OnPlayerText doesn't recognize return 0, here's what I used:


if(cmdtext[0] == ';')
{
    for(new i = 0; i < 41; i++)
    {
        if(IsPlayerConnected(i) && GetPlayerTeam(i) == GetPlayerTeam(playerid))
        {
            newvar = FindPlayerIDFromString(tmp);
            format(tmp,sizeof(tmp),"[TEAM] %s: %s",gPlayers[newvar],cmdtext[1]);
            SendClientMessage(i,COLOR_GREEN,tmp);
        }
    }
    return 0;
}


Outputs (Wrong):
Quote
Ettans: ;message
[TEAM] Ettans: message

Whereas it should output:
Quote[TEAM] Ettans: message

Any idea what's wrong or is it VC-MP bug?