Raised This Month: $51 Target: $400
 12% 

New API and Syntax


Post New Thread Reply   
 
Thread Tools Display Modes
BassPower
Member
Join Date: Mar 2011
Location: Lithuania
Old 05-11-2017 , 07:53   Re: New API and Syntax
Reply With Quote #871

Quote:
Originally Posted by WildCard65 View Post
view_as<bool>(StringToInt(newVal));
thxs

how
decl String:prefix[64], String:senderName[MAX_NAME_LENGTH], String:textMessage[MAXLENGTH_MESSAGE], String:buffer[MAXLENGTH_INPUT];

i char, int, bool... not working
BassPower is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 05-11-2017 , 08:01   Re: New API and Syntax
Reply With Quote #872

Code:
char prefix[64], senderName[MAX_NAME_LENGTH], textMessage[MAXLENGTH_MESSAGE], buffer[MAXLENGTH_INPUT];
klippy is offline
BassPower
Member
Join Date: Mar 2011
Location: Lithuania
Old 05-11-2017 , 09:34   Re: New API and Syntax
Reply With Quote #873

and last question how fix it:

Quote:
client = ReadPackCell(pack);
int numClientsStart = ReadPackCell(pack);
int numClientsFinish;
new clients[numClientsStart];

for (int x = 0; x < numClientsStart; x++)
{
int buffer = ReadPackCell(pack);
if (IsValidClient(buffer))
{
clients[numClientsFinish++] = buffer;
PushArrayCell(recipients, buffer);
}
}
i use {new clients[numClientsStart];} for char, bool, float not working any ideas?

Last edited by BassPower; 05-11-2017 at 09:35.
BassPower is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 05-11-2017 , 13:42   Re: New API and Syntax
Reply With Quote #874

int[] clients = new int[numClientsStart];
__________________
Peace-Maker is offline
BassPower
Member
Join Date: Mar 2011
Location: Lithuania
Old 05-12-2017 , 03:51   Re: New API and Syntax
Reply With Quote #875

Quote:
Originally Posted by Peace-Maker View Post
int[] clients = new int[numClientsStart];
thanks man - now i writed plugin to new syntax and working good no errors for new sourcemod
BassPower is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 05-13-2017 , 03:41   Re: New API and Syntax
Reply With Quote #876

Quote:
Originally Posted by BassPower View Post
thanks man - now i writed plugin to new syntax and working good no errors for new sourcemod
You can also learn some by using this tool I developed (provided you have Microsoft Excel).
https://forums.alliedmods.net/showthread.php?t=290805

I'll be porting it over to PHP here soon, but it will take a bit of time. Once done, I'll put the PHP project up on github. The VBA (MS Excel) version currently handles most of the conversion, including the dynamically sized array you noted above. The one notable (IMO) conversion it currently lacks is conversion of code doing type coercion (where view_as<> is required). But it should get you most of the way there in a matter of seconds. Will update that thread when the PHP version is up and running.
__________________

Last edited by ThatOneGuy; 05-13-2017 at 04:01.
ThatOneGuy is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 05-18-2017 , 14:34   Re: New API and Syntax
Reply With Quote #877

Can anyone tell me the new syntax of:

new const String:Z_DIFFICULTY[] = "Normal";

Last edited by Visual77; 05-18-2017 at 14:36.
Visual77 is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 05-18-2017 , 14:38   Re: New API and Syntax
Reply With Quote #878

Quote:
Originally Posted by Visual77 View Post
Can anyone tell me the new syntax of:

new const String:Z_DIFFICULTY[] = "Normal";
That const isn't doing anything.

PHP Code:
char Z_DIFFICULTY[] = "Normal"
__________________
asherkin is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 05-18-2017 , 14:57   Re: New API and Syntax
Reply With Quote #879

Quote:
Originally Posted by asherkin View Post
That const isn't doing anything.

PHP Code:
char Z_DIFFICULTY[] = "Normal"
I get an error.

Code:
keep_vs.sp(8) : error 162: cannot create dynamic arrays in global scope - did you mean to create a fixed-length array with brackets after the variable name?
Visual77 is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 05-18-2017 , 15:00   Re: New API and Syntax
Reply With Quote #880

Quote:
Originally Posted by Visual77 View Post
I get an error.

Code:
keep_vs.sp(8) : error 162: cannot create dynamic arrays in global scope - did you mean to create a fixed-length array with brackets after the variable name?
Fine here.

PHP Code:
#include <sourcemod>

#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo = {
    
name        "",
    
author      "",
    
description "",
    
version     "0.0.0",
    
url         ""
};

char Z_DIFFICULTY[] = "Normal";

public 
void OnPluginStart()
{
    
PrintToServer("Hello, World! %s"Z_DIFFICULTY);

Code:
SourcePawn Compiler 1.9.0.5921
Copyright (c) 1997-2006 ITB CompuPhase
Copyright (c) 2004-2015 AlliedModders LLC

Code size:             2964 bytes
Data size:             2296 bytes
Stack/heap size:      16384 bytes
Total requirements:   21644 bytes
__________________
asherkin 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 07:45.


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