Raised This Month: $209 Target: $400
 52% 

Array


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ambn
Veteran Member
Join Date: Feb 2015
Location: Fun servers
Old 02-01-2017 , 08:16   Array
Reply With Quote #1

hi, i'm making a simple plugin and i have a small problem , i kinda don't know how to make it work,
i'm trying to assign a string to an array and i've googled but found nothing of use ,
PHP Code:
PlayerArmPath[param1] = ArmPath;
PlayerSkinPath[param1] = SkinPath
i've got ArmPath and SkinPath from a keyvalue file via KvGetString and stored it into Those Strings (ArmsPath & SkinPath) , but when i do what i did , i get compile errors , how can i make it work?
NOTE : PlayerSkinPath[param1] and the other string are global , per player strings ,
i might look like a noob but can someone please help me make it work?
__________________
ambn is offline
Addicted.
AlliedModders Donor
Join Date: Dec 2013
Location: 0xA9D0DC
Old 02-01-2017 , 08:32   Re: Array
Reply With Quote #2

PHP Code:
StrCopy(char[] destint destLen, const char[] source
https://sm.alliedmods.net/new-api/string/strcopy

Last edited by Addicted.; 02-01-2017 at 08:33.
Addicted. is offline
Kailo
Senior Member
Join Date: Sep 2014
Location: Moscow, Russia
Old 02-01-2017 , 08:36   Re: Array
Reply With Quote #3

You can do like
PHP Code:
PlayerArmPath[param1] = ArmPath;
PlayerSkinPath[param1] = SkinPath
Then PlayerArmPath[] and ArmPath have equal size else use strcopy.
Kailo is offline
ambn
Veteran Member
Join Date: Feb 2015
Location: Fun servers
Old 02-01-2017 , 09:26   Re: Array
Reply With Quote #4

so then it would be like this?
Quote:
StrCopy(PlayerArmPath, sizeof(PlayerArmPath), ArmPath);
StrCopy(PlayerSkinPath, sizeof(PlayerSkinPath), SkinPath);
but it does not make sense , i'm trying to set parma1 String to something but does sizeof does it? i'm not sure if it do ...
__________________

Last edited by ambn; 02-01-2017 at 09:32.
ambn is offline
Michael Shoe Maker
Senior Member
Join Date: Apr 2016
Old 02-01-2017 , 09:43   Re: Array
Reply With Quote #5

Quote:
Originally Posted by ambn View Post
so then it would be like this?

but it does not make sense , i'm trying to set parma1 String to something but does sizeof does it? i'm not sure if it do ...
StrCopy(PlayerArmPath[param1], sizeof(PlayerArmPath[]), ArmPath);
StrCopy(PlayerSkinPath[param1], sizeof(PlayerSkinPath[]), SkinPath);
Michael Shoe Maker is offline
ambn
Veteran Member
Join Date: Feb 2015
Location: Fun servers
Old 02-01-2017 , 09:59   Re: Array
Reply With Quote #6

Quote:
Originally Posted by Michael Shoe Maker View Post
StrCopy(PlayerArmPath[param1], sizeof(PlayerArmPath[]), ArmPath);
StrCopy(PlayerSkinPath[param1], sizeof(PlayerSkinPath[]), SkinPath);
I tryed
PHP Code:
PrintToChatAll("%s skin %s arm"PlayerSkinPath[client], PlayerArmPath[client]); 
and it returned NULL after using this ,
what now?
__________________
ambn is offline
Michael Shoe Maker
Senior Member
Join Date: Apr 2016
Old 02-01-2017 , 10:34   Re: Array
Reply With Quote #7

Quote:
Originally Posted by ambn View Post
I tryed
PHP Code:
PrintToChatAll("%s skin %s arm"PlayerSkinPath[client], PlayerArmPath[client]); 
and it returned NULL after using this ,
what now?
How have you defined PlayerArmPath
Michael Shoe Maker is offline
ambn
Veteran Member
Join Date: Feb 2015
Location: Fun servers
Old 02-01-2017 , 10:40   Re: Array
Reply With Quote #8

Quote:
Originally Posted by Michael Shoe Maker View Post
How have you defined PlayerArmPath
It's a Global String Like This:
PHP Code:
new String:PlayerSkinPath[MAXPLAYERS 1]; 
__________________
ambn is offline
Kolapsicle
Senior Member
Join Date: Oct 2014
Old 02-01-2017 , 10:52   Re: Array
Reply With Quote #9

You're creating a string with the size of MAXPLAYERS so I'm going to assume you want a string per client?

PHP Code:
char PlayerSkinPath[MAXPLAYERS 1][64];
Format(PlayerSkinPath[client], sizeof(PlayerSkinPath[]), SkinPath); 

Last edited by Kolapsicle; 02-01-2017 at 10:52.
Kolapsicle is offline
ambn
Veteran Member
Join Date: Feb 2015
Location: Fun servers
Old 02-01-2017 , 10:58   Re: Array
Reply With Quote #10

Quote:
Originally Posted by Kolapsicle View Post
You're creating a string with the size of MAXPLAYERS so I'm going to assume you want a string per client?

PHP Code:
char PlayerSkinPath[MAXPLAYERS 1][64];
Format(PlayerSkinPath[client], sizeof(PlayerSkinPath[]), SkinPath); 
ok , let me test it and i'll let you know if it works.
__________________
ambn is offline
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

Forum Jump


All times are GMT -4. The time now is 12:58.


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