Raised This Month: $32 Target: $400
 8% 

Country/Capitals


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   ALL        Category:   Admin Commands       
TheWhitesmith
Senior Member
Join Date: Oct 2017
Location: Morocco :c
Old 11-24-2017 , 20:29   Country/Capitals
Reply With Quote #1

Country/Capitals

Description:
This is a simple plugin that I built for my Jailbreak server, since I havent found something similar I am posting it here. Speaking about countries and capitals, you guys should know what this plugin does.


Natives & Usage:
PHP Code:
//Generates a random country and its capital.
//Param1: String to store Country Name in.
//Param2: String Length.
//Param3: String to store Capital Name in.
//Param4: String Length.
//Return: 1 on success, 0 otherwise.
native get_random_capital(szCountry[], iLen1szCapital[], iLen2)

//Gives capital name for a given Country name (Country name must be complete)
//Param1: Country Name (case insensitive).
//Param2: String to store Capital Name in (If country name is correct).
//Param3: String Length.
//Return: 1 if country name found, 0 otherwise.
native get_capital_name(const szCountry[], szCapital[], iLen)

//Gives country name for a given Capital name (complete name or part of it)
//Param1: Capital Name (case insensitive).
//Param2: String to store Country Name in (If capital name is correct).
//Param3: String Length.
//Return: -1 if Param1 is less than 3 chars, 1 if capital name found, 0 otherwise.
native get_country_name(const szCapital[], szCountry[], iLen

How to use:
If you are interested in using this, put the plugin in your server, also download capitals.inc and put it in your includes folder.
If you don't know how to use natives, or you faced some problems, just write it down here and I'll try to do my best!
Attached Files
File Type: sma Get Plugin or Get Source (capitals.sma - 442 views - 7.8 KB)
File Type: inc capitals.inc (262 Bytes, 184 views)
TheWhitesmith is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 11-24-2017 , 23:46   Re: Country/Capitals
Reply With Quote #2

Do your native still need to use geoip module?
zmd94 is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 11-25-2017 , 05:00   Re: Country/Capitals
Reply With Quote #3

Quote:
Originally Posted by zmd94 View Post
Do your native still need to use geoip module?
It doesn't retrieve player's Country/Capital, it just retrieves Countries/Capitals from g_CountryCapitals[][][] array.
__________________
edon1337 is offline
TheWhitesmith
Senior Member
Join Date: Oct 2017
Location: Morocco :c
Old 11-25-2017 , 08:06   Re: Country/Capitals
Reply With Quote #4

Quote:
Originally Posted by zmd94 View Post
Do your native still need to use geoip module?
As edon said, it doesnt. This is a simple plugin which provides Capital names for each Country (Almost all the countries of the world).
__________________
TheWhitesmith is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 11-25-2017 , 09:43   Re: Country/Capitals
Reply With Quote #5

You should take a look on some tutotirals on how to use natives. Your code is very bad. Hardcoding everything inside it is also bad.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
TheWhitesmith
Senior Member
Join Date: Oct 2017
Location: Morocco :c
Old 11-26-2017 , 09:22   Re: Country/Capitals
Reply With Quote #6

So what do you suggest? Loading Capital names from .txt file? And please let me know what's wrong in my code.
__________________
TheWhitesmith is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 11-26-2017 , 10:44   Re: Country/Capitals
Reply With Quote #7

As deep as I can imagine, you can use this for a "Find the capital city" game.
__________________
Relaxing is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-26-2017 , 14:27   Re: Country/Capitals
Reply With Quote #8

Quote:
Originally Posted by TheWhitesmith View Post
you guys should know what this plugin does.
Umm . . . no. Your description should say what the plugin does.
__________________
fysiks is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 11-26-2017 , 18:40   Re: Country/Capitals
Reply With Quote #9

Quote:
Originally Posted by TheWhitesmith View Post
So what do you suggest? Loading Capital names from .txt file? And please let me know what's wrong in my code.
Style 1 natives should not be used.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
TheWhitesmith
Senior Member
Join Date: Oct 2017
Location: Morocco :c
Old 11-27-2017 , 13:07   Re: Country/Capitals
Reply With Quote #10

Quote:
Originally Posted by Relaxing View Post
As deep as I can imagine, you can use this for a "Find the capital city" game.
Yup, that's why I've made this plugin for my Jailbreak server.

Quote:
Originally Posted by fysiks View Post
Umm . . . no. Your description should say what the plugin does.
Well, I did.
PHP Code:
//Generates a random country and its capital. 
//Gives capital name for a given Country name (Country name must be complete) 
//Gives country name for a given Capital name (complete name or part of it) 
Quote:
Originally Posted by OciXCrom View Post
Style 1 natives should not be used.
Any reason?
__________________
TheWhitesmith is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 18:09.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode