[Include] CreateCity - Make Your Own Cities
#1

Introduction:


|* --------------------- *|
Anything in the red text means its new.
|* --------------------- *|

Its a really small include actually, I been working on it for a while because my mind just can't stick to one thing no matter how simple it is. I made this include because of a post I seen on my forum surf.

Functions/Callbacks:


Add this under #include <a_samp>

pawn Код:
#include <City>
Only 4 functions and 2 callbacks

Quote:

* CityCreate(cityname[], Float:minx, Float:miny, Float:maxx, Float:maxy) cityname[] = "NAME" Create-A-City
* CityCreateForPlayer(cityname[], playerid, Float:minx, Float:miny, Float:maxx, Float:maxy) cityname[] = "NAME" Create-A-City
* IsObjectInCity(objectid, cityid)
* IsPlayerInCity(playerid, cityid);
* DestroyCity(cityid);
* GetPlayerCity(playerid);
*
* Callbacks
*
* OnPlayerEnterCity(playerid,cityid)
* OnPlayerExitCity(playerid,cityid)
* Those are needed in the script in order to compile.

Use of Functions/Callbacks:

Well first for CreateCity you have this

Код:
CityCreate(cityname[], Float:minx, Float:miny, Float:maxx, Float:maxy)
CityCreateForPlayer(cityname[], playerid, Float:minx, Float:miny, Float:maxx, Float:maxy)
So lets say you wanna create LV so you would do this
Код:
CityCreate("LasVenturas", 805.7734, 525.5044, 2919.469, 2942.825);
CityCreateForPlayer("LasVenturas", playerid,805.7734, 525.5044, 2919.469, 2942.825); // This will create it for ONLY the player (If it is under OnPlayerSpawn OnPlayerConnect etc
That would create a rectangle around LV

Next is IsPlayerInCity(playerid, cityid);

You would just use this in any callback you have basically to see if the player is in a certain city like
pawn Код:
if(IsPlayerInCity(playerid,LV) == true)
{
        GivePlayerCash(playerid,20000);
}
Now onto DestroyCity(cityid);
This is the basic Destruction of the city mostly used OnFilterScriptExit or OnGameModeInIt

And last function is GetPlayerCity(playerid);
This actually just another IsPlayerInCity but this is used to get the players current city (tested and it works for command)

Now for the CallBacks

First is OnPlayerEnterCity(playerid,cityid) I'll just show you what i had.
pawn Код:
public OnPlayerEnterCity(playerid,cityid)
{
    if(cityid == LV)
    {
        SendClientMessage(playerid,0x67F6F6AA,"You have entered the city Las Venturas!");
    }
    return 1;
}
And with OnPlayerExitCity(playerid,cityid) its kinda the same way....
pawn Код:
public OnPlayerExitCity(playerid,cityid)
{
    if(cityid == LV)
    {
        SendClientMessage(playerid,0x67F6F6AA,"You have left Las Venturas");
    }
    return 1;
}
IsObjectInCity(objectid, cityid);
pawn Код:
public OnFilterscriptInIt()
{
       if(IsObjectInCity(testO, LV))
       {      
                 print("testO object is in Las Venturas");
       }
       return 1;
}
The callbacks are set on a timer so it will detect every half second? if the player has entered or exited the city, and no it don't spam the chat with it, it only sends once until re enter or exit.

Downloads:


Cities.INC file - Pastebin
Cities Example FS - Pastebin
http://www.mediafire.com/?e2r9i2s0ns...ST FS AMX File - Media Fire
http://www.mediafire.com/?65kylyzca2...st FS PWN File - Media Fire
http://www.mediafire.com/?lg8r7hu808w7gz9]City.INC - Media Fire

Credits:

Las Venturas CNR for the CreateCityForPlayer idea.

Bugs

I can't find any bugs mostly because I don't have a test partner. If you find any please post here.

NOTE: CreateCityForPlayer was tested with me and me only.

Hope this help some of you.

Код:
/*
 * @version   : v3
 * @author    : willsuckformoney (FrosTiC)
 * @date      : September 4, 2010
 * @update    : November 1, 2010
 *
 * The basics and the Funcions/Uses.
 *
 * What can use?
 * CityCreateForPlayer(cityname[], playerid, Float:minx, Float:miny, Float:maxx, Float:maxy)		cityname[] = "NAME"     Create-A-City
 * CityCreate(cityname[], Float:minx, Float:miny, Float:maxx, Float:maxy)		cityname[] = "NAME"     Create-A-City
 * IsPlayerInCity(playerid, cityid);
 * DestroyCity(cityid);
 * GetPlayerCity(playerid);
 * |* REMOVED *|
 *
 * Callbacks
 *
 * OnPlayerEnterCity(playerid,cityid)
 * OnPlayerExitCity(playerid,cityid)
 * Those are needed in the script in order to compile.
*/
Reply
#2

It might be usefull Good job
Reply
#3

Nice! Useful for RP (:
Reply
#4

Thanks ||
Reply
#5

Very nice mate,a lot of people looked for something like this :d
Reply
#6

That's main reason I did this
Reply
#7

This would come in handy making the Loading screens when changing cities in VC and LC
Reply
#8

Very nice +10
Reply
#9

thanks kitten and [L3th4l] I never really though of that
Reply
#10

Any suggestions? Anything i should add?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)