Raised This Month: $ Target: $400
 0% 

Argument Mismatch + Invalid Expression


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Cyb3rH4Xter
Senior Member
Join Date: May 2009
Location: Sweden
Old 04-14-2011 , 11:28   Argument Mismatch + Invalid Expression
Reply With Quote #1

I have edited a plugin that enables RTV for another plugin, but now I am getting a few errors when compiling this code:

Code:
/*
 *    RockTheVote for Polymorph
 *    Requires Polymorph v0.8.2 or later
 *
 */

#include <amxmodx>
#include <amxmisc>
// #include <polymorph>

native polyn_votemod()

new bool:g_rockedVote[33], g_rockedVoteCnt
new bool:g_hasbeenrocked = false
new RoundCount;

// Cvars
new cvar_rtv_enabled
new cvar_rtv_ratio
new cvar_rtv_show

public plugin_init()
{
    register_plugin("Polymorph: RockTheVote", "1.0", "Fysiks")
    
    register_clcmd("amx_rtv","cmdAdminRTV", ADMIN_MAP, " Manually RockTheVote")
    register_clcmd("admin_rtv","cmdAdminRTV", ADMIN_MAP, " Manually RockTheVote")
    register_clcmd("say rtv", "cmdSayRTV")
    register_clcmd("say rockthevote", "cmdSayRTV")
    
    register_logevent("logevent_RoundStart", 2, "1=Round_Start");
    
    // Cvars
    cvar_rtv_enabled = register_cvar("rtv_enable", "1")    // <0|1>
    cvar_rtv_ratio = register_cvar("rtv_ratio", "0.51")        // Use amx_votemap_ratio?
    cvar_rtv_show = register_cvar("rtv_show", "1")        // Display how many more votes needed to rtv
}

public logevent_RoundStart() {
    RoundCount++;
}

public cmdAdminRTV(id, level, cid)
{
    if(!cmd_access(id,level,cid,1))
        return PLUGIN_HANDLED
    
    if(g_hasbeenrocked)
    {
        client_print(id,print_console,"[RTV] Vote has already been rocked")
    }
    else
    {
        g_hasbeenrocked = true
        new admin_name[32]
        get_user_name(id, admin_name, 31)
        show_activity(id, admin_name, "has RockedTheVote")
        client_print(id,print_console, "[RTV] You have RockedTheVote")
        set_task(3.5,"announce_vote")
        set_task(5.0,"startRockVote")
    }
    // Add functionality to cancel rocked vote.
    return PLUGIN_HANDLED
}

public client_connect(id)
{
    g_rockedVote[id] = false
}

public client_disconnect(id)
{
    if(g_rockedVote[id])
    {
        g_rockedVote[id] = false
        g_rockedVoteCnt--
    }
}

public cmdSayRTV(id)
{
    if(!get_pcvar_num(cvar_rtv_enabled))
        return PLUGIN_CONTINUE // PLUGIN_HANDLED
    
    if(g_hasbeenrocked)
    {
        client_print(id, print_chat, "[RTV] Vote has already been Rocked.")
        return PLUGIN_HANDLED
    }
    
    if(g_rockedVote[id])
    {
        client_print(id, print_chat, "[RTV] You already voted.")
        rtv_remind()
        return PLUGIN_CONTINUE  // PLUGIN_HANDLED for blind?
    }
    
    if( get_pcvar_float("mp_timelimit") != 0 )
    {
        if(get_timeleft() < 240 ) // don't allow rtv 4 minutes before map ends
        {
            client_print(id, print_chat, "[RTV] Too Late to RockTheVote.")
            return PLUGIN_HANDLED
        }
    }
    else if( get_pcvar_float("mp_maxrounds") != 0 )
    {
        new Float:roundsLeft = get_pcvar_float("mp_maxrounds") - RoundCount
        
        if( roundsLeft <= 4) ) // don't allow rtv 4 rounds before map ends
        {
            client_print(id, print_chat, "[RTV] Too Late to RockTheVote.")
            return PLUGIN_HANDLED
        }
    }
    
    // You (id) just voted to rock.
    g_rockedVote[id] = true
    g_rockedVoteCnt++
    client_print(id,print_chat, "[RTV] You chose to RockTheVote")
    
    if( g_rockedVoteCnt >= get_RocksNeeded() )     // Decide if we rock the vote
    {
        g_hasbeenrocked = true
        client_print(0,print_chat, "[RTV] The Vote has been Rocked!")
        set_task(3.5,"announce_vote")
        set_task(5.0,"startRockVote")
    }
    else
    {
        rtv_remind()
    }
    
    return PLUGIN_CONTINUE
}

public startRockVote()
{
    polyn_votemod()
}

get_RocksNeeded()
{
    return floatround(get_pcvar_float(cvar_rtv_ratio) * float(get_realplayersnum()), floatround_ceil);
}

stock get_realplayersnum()
{
    new players[32], playerCnt;
    get_players(players, playerCnt, "ch");
    
    return playerCnt;
}

rtv_remind()
{
    if(get_pcvar_num(cvar_rtv_show))
    {  // Not tested yet.
        client_print(0,print_chat, "[RTV] Need %d more players to RockTheVote.", get_RocksNeeded() - g_rockedVoteCnt)
    }
}

public announce_vote()
{
    client_cmd(0, "spk buttons/blip2")  // Moved here from startRockVote to give heads up
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ ansicpg1252\\ deff0\\ deflang1053{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ f0\\ fs16 \n\\ par }
*/
The errors are on line 98, 106, 108, 110.
Would be awesome if somebody told me whats wrong. Am a newbie pawn coder, normally a C# coder
Cyb3rH4Xter is offline
kotinha
Senior Member
Join Date: Jun 2009
Location: Alentejo, Portugal :)
Old 04-14-2011 , 11:41   Re: Argument Mismatch + Invalid Expression
Reply With Quote #2

PHP Code:
/*
 *    RockTheVote for Polymorph
 *    Requires Polymorph v0.8.2 or later
 *
 */

#include <amxmodx>
#include <amxmisc>
// #include <polymorph>

native polyn_votemod()

new 
bool:g_rockedVote[33], g_rockedVoteCnt
new bool:g_hasbeenrocked false
new RoundCount;

// Cvars
new cvar_rtv_enabled
new cvar_rtv_ratio
new cvar_rtv_show

public plugin_init()
{
    
register_plugin("Polymorph: RockTheVote""1.0""Fysiks")
    
    
register_clcmd("amx_rtv","cmdAdminRTV"ADMIN_MAP" Manually RockTheVote")
    
register_clcmd("admin_rtv","cmdAdminRTV"ADMIN_MAP" Manually RockTheVote")
    
register_clcmd("say rtv""cmdSayRTV")
    
register_clcmd("say rockthevote""cmdSayRTV")
    
    
register_logevent("logevent_RoundStart"2"1=Round_Start");
    
    
// Cvars
    
cvar_rtv_enabled register_cvar("rtv_enable""1")    // <0|1>
    
cvar_rtv_ratio register_cvar("rtv_ratio""0.51")        // Use amx_votemap_ratio?
    
cvar_rtv_show register_cvar("rtv_show""1")        // Display how many more votes needed to rtv
}

public 
logevent_RoundStart() {
    
RoundCount++;
}

public 
cmdAdminRTV(idlevelcid)
{
    if(!
cmd_access(id,level,cid,1))
        return 
PLUGIN_HANDLED
    
    
if(g_hasbeenrocked)
    {
        
client_print(id,print_console,"[RTV] Vote has already been rocked")
    }
    else
    {
        
g_hasbeenrocked true
        
new admin_name[32]
        
get_user_name(idadmin_name31)
        
show_activity(idadmin_name"has RockedTheVote")
        
client_print(id,print_console"[RTV] You have RockedTheVote")
        
set_task(3.5,"announce_vote")
        
set_task(5.0,"startRockVote")
    }
    
// Add functionality to cancel rocked vote.
    
return PLUGIN_HANDLED
}

public 
client_connect(id)
{
    
g_rockedVote[id] = false
}

public 
client_disconnect(id)
{
    if(
g_rockedVote[id])
    {
        
g_rockedVote[id] = false
        g_rockedVoteCnt
--
    }
}

public 
cmdSayRTV(id)
{
    if(!
get_pcvar_num(cvar_rtv_enabled))
        return 
PLUGIN_CONTINUE // PLUGIN_HANDLED
    
    
if(g_hasbeenrocked)
    {
        
client_print(idprint_chat"[RTV] Vote has already been Rocked.")
        return 
PLUGIN_HANDLED
    
}
    
    if(
g_rockedVote[id])
    {
        
client_print(idprint_chat"[RTV] You already voted.")
        
rtv_remind()
        return 
PLUGIN_CONTINUE  // PLUGIN_HANDLED for blind?
    
}
    
    if( 
get_pcvar_num("mp_timelimit") != )
    {
        if(
get_timeleft() < 240 // don't allow rtv 4 minutes before map ends
        
{
            
client_print(idprint_chat"[RTV] Too Late to RockTheVote.")
            return 
PLUGIN_HANDLED
        
}
    }
    else if( 
get_pcvar_num("mp_maxrounds") != )
    {
        new 
Float:roundsLeft get_pcvar_num("mp_maxrounds") - RoundCount
        
        
if( roundsLeft <= // don't allow rtv 4 rounds before map ends
        
{
            
client_print(idprint_chat"[RTV] Too Late to RockTheVote.")
            return 
PLUGIN_HANDLED
        
}
    }
    
    
// You (id) just voted to rock.
    
g_rockedVote[id] = true
    g_rockedVoteCnt
++
    
client_print(id,print_chat"[RTV] You chose to RockTheVote")
    
    if( 
g_rockedVoteCnt >= get_RocksNeeded() )     // Decide if we rock the vote
    
{
        
g_hasbeenrocked true
        client_print
(0,print_chat"[RTV] The Vote has been Rocked!")
        
set_task(3.5,"announce_vote")
        
set_task(5.0,"startRockVote")
    }
    else
    {
        
rtv_remind()
    }
    
    return 
PLUGIN_CONTINUE
}

public 
startRockVote()
{
    
polyn_votemod()
}

get_RocksNeeded()
{
    return 
floatround(get_pcvar_float(cvar_rtv_ratio) * float(get_realplayersnum()), floatround_ceil);
}

stock get_realplayersnum()
{
    new 
players[32], playerCnt;
    
get_players(playersplayerCnt"ch");
    
    return 
playerCnt;
}

rtv_remind()
{
    if(
get_pcvar_num(cvar_rtv_show))
    {  
// Not tested yet.
        
client_print(0,print_chat"[RTV] Need %d more players to RockTheVote."get_RocksNeeded() - g_rockedVoteCnt)
    }
}

public 
announce_vote()
{
    
client_cmd(0"spk buttons/blip2")  // Moved here from startRockVote to give heads up
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ ansicpg1252\\ deff0\\ deflang1053{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ f0\\ fs16 \n\\ par }
*/ 
__________________
"If God exists, I hope he has a good excuse." - Woody Allen
kotinha is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 04-14-2011 , 11:42   Re: Argument Mismatch + Invalid Expression
Reply With Quote #3

Code:
get_pcvar_float("mp_timelimit")

Code:
get_cvar_pointer("mp_timelimit")
Code:
 new Float:roundsLeft = get_cvar_pointer("mp_maxrounds") - RoundCount
        
        if( roundsLeft <= 4) )

Code:
 new roundsLeft = get_cvar_pointer("mp_maxrounds") - RoundCount
        
        if( roundsLeft <= 4)
Another thing is that you check if a float value is other than an integer.

Last edited by SpeeDeeR; 04-14-2011 at 11:45.
SpeeDeeR is offline
Cyb3rH4Xter
Senior Member
Join Date: May 2009
Location: Sweden
Old 04-14-2011 , 11:54   Re: Argument Mismatch + Invalid Expression
Reply With Quote #4

Great, fix those 2 things. Now I only have one error a a warning left at this area:

PHP Code:
        new Float:roundsLeft get_cvar_pointer("mp_maxrounds") - RoundCount
        
        
if( roundsLeft <= 4.0) ) // don't allow rtv 4 rounds before map ends
        
{
            
client_print(idprint_chat"[RTV] Too Late to RockTheVote.")
            return 
PLUGIN_HANDLED
        

The error and warning is on the if (roundsLeft..... line.
Its a tag mismatch and a invalid expression :S
Cyb3rH4Xter is offline
kotinha
Senior Member
Join Date: Jun 2009
Location: Alentejo, Portugal :)
Old 04-14-2011 , 11:59   Re: Argument Mismatch + Invalid Expression
Reply With Quote #5

I corrected you wrongly up there

You didn't remove the ) from this:
PHP Code:
if( roundsLeft <= 4.0) ) 
__________________
"If God exists, I hope he has a good excuse." - Woody Allen
kotinha is offline
Cyb3rH4Xter
Senior Member
Join Date: May 2009
Location: Sweden
Old 04-14-2011 , 12:25   Re: Argument Mismatch + Invalid Expression
Reply With Quote #6

Oops missed that one, now there is just one error left:
Tag mismatch at the same line:

PHP Code:
        new Float:roundsLeft get_cvar_pointer("mp_maxrounds") - RoundCount
        
        
if( roundsLeft <= 4.0 // don't allow rtv 4 rounds before map ends 
Awesome fast help here
Cyb3rH4Xter is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 04-14-2011 , 12:26   Re: Argument Mismatch + Invalid Expression
Reply With Quote #7

Quote:
Originally Posted by SpeeDeeR View Post
Code:
 new Float:roundsLeft = get_cvar_pointer("mp_maxrounds") - RoundCount
        
        if( roundsLeft <= 4) )

Code:
 new roundsLeft = get_cvar_pointer("mp_maxrounds") - RoundCount
        
        if( roundsLeft <= 4)
You check if a float value is less or equal to an integer one and that triggers tag mismatch BECAUSE ITS WRONG.
You really code C# ?

Last edited by SpeeDeeR; 04-14-2011 at 12:30.
SpeeDeeR is offline
kotinha
Senior Member
Join Date: Jun 2009
Location: Alentejo, Portugal :)
Old 04-14-2011 , 12:27   Re: Argument Mismatch + Invalid Expression
Reply With Quote #8

nvm, SpeedDeeR posted it first lol
__________________
"If God exists, I hope he has a good excuse." - Woody Allen

Last edited by kotinha; 04-14-2011 at 12:30.
kotinha is offline
Cyb3rH4Xter
Senior Member
Join Date: May 2009
Location: Sweden
Old 04-14-2011 , 12:51   Re: Argument Mismatch + Invalid Expression
Reply With Quote #9

Quote:
Originally Posted by SpeeDeeR View Post
You check if a float value is less or equal to an integer one and that triggers tag mismatch BECAUSE ITS WRONG.
You really code C# ?
Yes I code C#, maybe I am not that experienced in it but I have written 2300 lines in my current project and it works well, but usually I am used a easier-to-use debugger and why I wrote that is because I know there are differences in these 2 languages. For example I tried to declare an int but there was no such thing so I went with float. Apparently it becomes an int if you don't specify any type lol. Secondly, of course I know you can't match one type of variable with one of another type, but how the heck should I know how to convert an int to a float if I never coded pawn before?
Cyb3rH4Xter is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 04-14-2011 , 13:01   Re: Argument Mismatch + Invalid Expression
Reply With Quote #10

Code Snippets/Tutorials

new a > int
new a[32] > string
new Array:a[32] > array
new Float:a > float
new bool:a > bool
new const a[] > const
new Trie:a > trie
SpeeDeeR 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 19:53.


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