SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 10/03/2018, 12:23 AM   #1
stormchaser206
Gangsta
 
stormchaser206's Avatar
 
Join Date: Jan 2012
Location: United States of America
Posts: 695
Reputation: 46
Default GetPlayerTeamName custom function doesn't work

Code:
GetPlayerTeamName(playerid)
{
    new szString[24];
    new team;
    team = GetPlayerTeam(playerid);

    switch(team)
    {
        case 5000: szString = "United States";
        case 5001: szString = "Canada";
        case 5002: szString = "Britain";
        case 5003: szString = "Australia";
        case 5004: szString = "Russia";
        case 5005: szString = "Germany";
        case 5006: szString = "Italy";
        case 5007: szString = "France";
        case 5008: szString = "China";
        case 5009: szString = "India";
    }
    return szString;
}
I have that as a custom function but whenever I use it, it doesn't put anything in-game. Just blank.

Example: https://i.imgur.com/ZTBoUHJ.png
The team name should be at the end.
stormchaser206 is offline   Reply With Quote
Old 10/03/2018, 05:49 AM   #2
KayJ
Gangsta
 
KayJ's Avatar
 
Join Date: Apr 2014
Posts: 684
Reputation: 64
Default Re: GetPlayerTeamName custom function doesn't work

Why do you use cases in large numbers?
KayJ is offline   Reply With Quote
Old 10/03/2018, 06:43 PM   #3
stormchaser206
Gangsta
 
stormchaser206's Avatar
 
Join Date: Jan 2012
Location: United States of America
Posts: 695
Reputation: 46
Default Re: GetPlayerTeamName custom function doesn't work

Quote:
Originally Posted by KayJ View Post
Why do you use cases in large numbers?
Because someone else here suggested it. Those are just the team IDs.
stormchaser206 is offline   Reply With Quote
Old 10/03/2018, 06:53 PM   #4
Stuntff
Big Clucker
 
Join Date: Feb 2016
Posts: 83
Reputation: 21
Default Re: GetPlayerTeamName custom function doesn't work

Code:
new const gTeamName[10][15] =
{
	"United States",
	"Canada",
	"Britain",
	"Australia",
	"Russia",
	"Germany",
	"Italy",
	"France",
	"China",
	"India"	
};

printf("team name = %s", gTeamName[GetPlayerTeam(playerid)-5000]);
No?
Stuntff is offline   Reply With Quote
Old 11/03/2018, 04:50 AM   #5
stormchaser206
Gangsta
 
stormchaser206's Avatar
 
Join Date: Jan 2012
Location: United States of America
Posts: 695
Reputation: 46
Default Re: GetPlayerTeamName custom function doesn't work

Is there any way I can keep my custom function?
stormchaser206 is offline   Reply With Quote
Old 11/03/2018, 05:02 AM   #6
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,268
Reputation: 525
Default Re: GetPlayerTeamName custom function doesn't work

There's no point to your function if you use the method he's shown.

You could integrate what he's shown into your function, but it sort of defeats the purpose of the method he's shown you in the first place.
Sew_Sumi is offline   Reply With Quote
Old 11/03/2018, 05:02 AM   #7
Dayrion
High-roller
 
Dayrion's Avatar
 
Join Date: Jan 2016
Location: France
Posts: 1,920
Reputation: 258
Default Re: GetPlayerTeamName custom function doesn't work

Use strcat instead of equal sign. This is a string, not a number.
__________________
actor_plus - v5.0.2
I'm a goner, somebody catch my breath,
I'm a goner, somebody catch my breath
Dayrion 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
IRC Chat Realy doesn't work with custom Chatting Sgt.TheDarkness Scripting Help 0 23/08/2012 11:54 PM
Function doesn't work Tomer!.$ Scripting Help 19 17/04/2012 07:00 PM
Function doesn't work kevin974 Help Archive 23 12/07/2010 07:25 PM
Why doesn't this function work? Norn Help Archive 6 05/09/2009 07:00 AM
Can playerid work in a custom function? HydraX Help Archive 1 21/05/2009 03:35 AM


All times are GMT. The time now is 04:47 PM.


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