SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 25/02/2008, 05:51 AM   #1
Cueball
Gangsta
 
Join Date: Jul 2007
Posts: 527
Reputation: 14
Default [INC] Zones By ~Cueball~ - V 2.0

ZONES INCLUDE
BY ~CUEBALL~

Hi everybody. After recently reading and chatting on IRC about the zones/areas of San Andreas, and how people wanted a function to get this much easier than a script that places this down the bottom of the players screen, I decided to put together this little include file which will make these things possible.

I wish for it to be known that this was inspired by Mabako's Zones Script.

I also wish to acknowledge those whose work made these functions possible:
_________________________________________________

Functions:
  • GetPlayer2DZone(playerid, zone[], len);
  • GetPlayer3DZone(playerid, zone[], len);
  • IsPlayerInZone(playerid, zone[]);

GetPlayer2DZone:
@Info: Used to retrieve the players zone/area name. DOES NOT COMPARE HEIGHTS!
@param: playerid - The id of the player whose zone you will retrieve.
@param: zone[] - The string with which the zone name will be formatted into.
@param: len - The maximum length you wish to format the zone name into. RECOMMENDED 28!


GetPlayer3DZone:
@Info: Used to retrieve the players zone/area name and comparing with heights.
@param: playerid - The id of the player whose zone you will retrieve.
@param: zone[] - The string with which the zone name will be formatted into.
@param: len - The maximum length you wish to format the zone name into. RECOMMENDED 28!


IsPlayerInZone:
@Info: Used to check if the player is inside the zone[] parameter.
@param: playerid - The id of the player whose zone you will check.
@param: zone[] - The string with which we will compare the players zone name to.


_________________________________________________

Possible Usage:

pawn Code:
#include <a_samp>
#include <a_zones>

public OnPlayerDeath(playerid, killerid, reason)
{
  new string[200], kName[MAX_PLAYER_NAME], zone[MAX_ZONE_NAME];
  GetPlayerName(playerid, string, MAX_PLAYER_NAME);
  GetPlayerName(killerid, kName, MAX_PLAYER_NAME);
  GetPlayer2DZone(playerid, zone, MAX_ZONE_NAME);
  format(string, sizeof(string), "Player \'%s\' was killed by \'%s\' at %s.", string, kName, zone);
  printf("%s", string);
  return 1;
}

public OnPlayerSpawn(playerid)
{
  if(IsPlayerInZone(playerid, "Sherman"))
    print("The player spawned at The Sherman Dam.");
  return 1;
}

If the players name is 'Simon' and the killers name is 'Cueball', and Simon was killed in Ganton, it will print this to the console:
Player 'Simon' was killed by 'Cueball' at Ganton.

When the player spawns, if he spawned at The Sherman Dam, it will print this to the console:
The player spawned at The Sherman Dam.

_________________________________________________

Change Log:

_________________________________________________

Downloads:

_________________________________________________

If you have any problems, please post them in this topic. With kind regards,
~Cueball~
Cueball is offline   Reply With Quote
Old 25/02/2008, 09:08 AM   #2
aroma
Little Clucker
 
Join Date: Feb 2008
Posts: 44
Reputation: 0
Default Re: [INC] Zones By ~Cueball~

Nice work i only get 2 errors

Code:
E:\Games\San Andreas\GTA San Andreas\samp\gamemodes\penlv.pwn(2671) : error 021: symbol already defined: "string"
E:\Games\San Andreas\GTA San Andreas\samp\gamemodes\penlv.pwn(2670) : warning 204: symbol is assigned a value that is never used: "string"
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


1 Error.

This is mine Public Onplayerdeath:

Code:
public OnPlayerDeath(playerid, killerid, reason)
{
	if (gdebug >=0){printf("OnPlayerDeath Playerid:%d killerid:%d reason:%d", playerid, killerid, reason);}
	SendDeathMessage(killerid, playerid, reason);
  new name[MAX_PLAYER_NAME];
	new string[256];
  new string[200], kName[MAX_PLAYER_NAME], zone[MAX_ZONE_NAME];
  GetPlayerName(playerid, string, MAX_PLAYER_NAME);
  GetPlayerName(killerid, kName, MAX_PLAYER_NAME);
  GetPlayer2DZone(playerid, zone, MAX_ZONE_NAME);
  format(string, sizeof(string), "Player \'%s\' was killed by \'%s\' at %s.", string, kName, zone);
  printf("%s", string);
	new dmessage[128];
	new deathreason[20];
	new playercash;
	new victimteam;
  new Float:px,Float:py,Float:pz;
	//new killerteam;
	victimteam = (gTeam[playerid]);
	//killerteam = (gTeam[killerid]);
  gPlayerSpawned[playerid] = 0;
  SetPlayerWantedLevel(playerid,0);
	GetPlayerName(playerid, name, sizeof(name));
	PlayerInfo[playerid][pLocal] = 255;
	GetPlayerPos(playerid, px, py, pz);
aroma is offline   Reply With Quote
Old 25/02/2008, 09:18 AM   #3
El0vric
Huge Clucker
 
Join Date: Nov 2006
Posts: 420
Reputation: 0
Default Re: [INC] Zones By ~Cueball~

You already defined the 'string'.

Read pawn-lang.pdf for errors/warnings.
El0vric is offline   Reply With Quote
Old 25/02/2008, 09:19 AM   #4
Cueball
Gangsta
 
Join Date: Jul 2007
Posts: 527
Reputation: 14
Default Re: [INC] Zones By ~Cueball~

Quote:
Originally Posted by aroma
Nice work i only get 2 errors

Code:
E:\Games\San Andreas\GTA San Andreas\samp\gamemodes\penlv.pwn(2671) : error 021: symbol already defined: "string"
E:\Games\San Andreas\GTA San Andreas\samp\gamemodes\penlv.pwn(2670) : warning 204: symbol is assigned a value that is never used: "string"
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


1 Error.

This is mine Public Onplayerdeath:

Code:
public OnPlayerDeath(playerid, killerid, reason)
{
	if (gdebug >=0){printf("OnPlayerDeath Playerid:%d killerid:%d reason:%d", playerid, killerid, reason);}
	SendDeathMessage(killerid, playerid, reason);
  new name[MAX_PLAYER_NAME];
	new string[256];
  new string[200], kName[MAX_PLAYER_NAME], zone[MAX_ZONE_NAME];
  GetPlayerName(playerid, string, MAX_PLAYER_NAME);
  GetPlayerName(killerid, kName, MAX_PLAYER_NAME);
  GetPlayer2DZone(playerid, zone, MAX_ZONE_NAME);
  format(string, sizeof(string), "Player \'%s\' was killed by \'%s\' at %s.", string, kName, zone);
  printf("%s", string);
	new dmessage[128];
	new deathreason[20];
	new playercash;
	new victimteam;
  new Float:px,Float:py,Float:pz;
	//new killerteam;
	victimteam = (gTeam[playerid]);
	//killerteam = (gTeam[killerid]);
  gPlayerSpawned[playerid] = 0;
  SetPlayerWantedLevel(playerid,0);
	GetPlayerName(playerid, name, sizeof(name));
	PlayerInfo[playerid][pLocal] = 255;
	GetPlayerPos(playerid, px, py, pz);
If you look closely at your compiler errors, they are in your script, not my include. But this is ok, because I can help you out anyway

pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
if (gdebug >=0){printf("OnPlayerDeath Playerid:%d killerid:%d reason:%d", playerid, killerid, reason);}
SendDeathMessage(killerid, playerid, reason);
  new name[MAX_PLAYER_NAME];
  //new string[256]; <-- You have declared the same variable 'string' twice.
  new string[200], //<-- You see?
  kName[MAX_PLAYER_NAME], zone[MAX_ZONE_NAME];
  GetPlayerName(playerid, string, MAX_PLAYER_NAME);
  GetPlayerName(killerid, kName, MAX_PLAYER_NAME);
  GetPlayer2DZone(playerid, zone, MAX_ZONE_NAME);
  format(string, sizeof(string), "Player \'%s\' was killed by \'%s\' at %s.", string, kName, zone);
  printf("%s", string);
    new dmessage[128];
    new deathreason[20];
    new playercash;
    new victimteam;
  new Float:px,Float:py,Float:pz;
    //new killerteam;
    victimteam = (gTeam[playerid]);
    //killerteam = (gTeam[killerid]);
  gPlayerSpawned[playerid] = 0;
  SetPlayerWantedLevel(playerid,0);
    GetPlayerName(playerid, name, sizeof(name));
    PlayerInfo[playerid][pLocal] = 255;
    GetPlayerPos(playerid, px, py, pz);

Remove the commented line (the one in green) and your error will be fixed.

~Cueball~
Cueball is offline   Reply With Quote
Old 25/02/2008, 10:40 AM   #5
FujiNNN
Huge Clucker
 
FujiNNN's Avatar
 
Join Date: Aug 2006
Location: Russia, Moscow
Posts: 311
Reputation: 0
Default Re: [INC] Zones By ~Cueball~

Wow thanks i will replance my makabo's with that for sure.
FujiNNN is offline   Reply With Quote
Old 25/02/2008, 02:54 PM   #6
[LDT]LuxurY
Gangsta
 
[LDT]LuxurY's Avatar
 
Join Date: Feb 2007
Location: Russian Federation, Orekhovo-Zyevo
Posts: 584
Reputation: 1
Default Re: [INC] Zones By ~Cueball~

nice work
[LDT]LuxurY is offline   Reply With Quote
Old 26/02/2008, 12:14 AM   #7
Cueball
Gangsta
 
Join Date: Jul 2007
Posts: 527
Reputation: 14
Default Re: [INC] Zones By ~Cueball~

Quote:
Originally Posted by FujiNNN
Wow thanks i will replance my makabo's with that for sure.
Thanks, but I want it to be known that I did not make this include to replace Mabako's Zones Script, rather to help reproduce a similar system. I am writing this so that Mabako does not come in here and rape me

And to [LDT]LuxurY, thanks

~Cueball~
Cueball is offline   Reply With Quote
Old 27/02/2008, 10:58 PM   #8
yom
High-roller
 
Join Date: Jul 2006
Posts: 2,002
Reputation: 6
Default Re: [INC] Zones By ~Cueball~

I don't understand why you need the parameters zone[] and len

Why not simply GetPlayerXDZone(playerid)
yom is offline   Reply With Quote
Old 27/02/2008, 11:01 PM   #9
Numhaken
Huge Clucker
 
Join Date: Jan 2008
Posts: 463
Reputation: 1
Default Re: [INC] Zones By ~Cueball~

Nice script.
Numhaken is offline   Reply With Quote
Old 29/02/2008, 08:58 AM   #10
Cueball
Gangsta
 
Join Date: Jul 2007
Posts: 527
Reputation: 14
Default Re: [INC] Zones By ~Cueball~

Quote:
Originally Posted by yom
I don't understand why you need the parameters zone[] and len

Why not simply GetPlayerXDZone(playerid)
I can see your point, but I thought I would do it this way, so that people can call it once, and then use it in their own strings. Len is needed because I format the 'zone[]' parameter with format() and I wished for the user to be able to choose the length to format it to.

Quote:
Originally Posted by Numhaken
Nice script.
Thanks

~Cueball~
Cueball is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] [FS] DM Zones BurningSWA Filterscripts 8 01/07/2012 12:39 PM
[Include] [INC]Trajectory - V 0.1 || By ~Cueball~ Cueball Includes 15 05/04/2012 04:21 PM
zones Lajko1 Help Archive 4 22/11/2009 05:35 PM
[FilterScript] [FS] D-Zones Domnage Filterscripts 2 23/09/2009 02:06 PM
A little problem with gang zones (only create gang zones) CTCCoco Help Archive 4 20/02/2009 11:59 AM


All times are GMT. The time now is 10:34 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.